Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sed -f
- #Increment integers. Handles multiple numbers per line.
- #bracket numbers with < >
- s/[0-9]\+/<&>/g
- #tail lines with how many times to increment, less one.
- #set addresses here to get multiple increments on selected lines
- /[0-9]\+/s/.*/& IIII/
- #start of increment loop
- :a
- # replace all trailing 9s by _
- :d
- s/9\(_*\)>/_\1>/
- td
- # incr last digit only. The last line adds a most-significant
- # digit of 1 if we have to add a digit.
- s/8\(_*\)>/9\1>/g
- s/7\(_*\)>/8\1>/g
- s/6\(_*\)>/7\1>/g
- s/5\(_*\)>/6\1>/g
- s/4\(_*\)>/5\1>/g
- s/3\(_*\)>/4\1>/g
- s/2\(_*\)>/3\1>/g
- s/1\(_*\)>/2\1>/g
- s/0\(_*\)>/1\1>/g
- s/<\(_*\)>/<1\1>/g
- #/[<0-8]_*>/s/.*/NumLine & numline/g
- #replace _ with 0
- y/_/0/
- #end of increment loop
- #first, an empty loop to 'flush' status
- tb;:b
- #remove one 'I' from the tail, and loop until none left
- s/ \(I*\)I$/ \1/; ta
- #remove < > bracketing
- s/<\([0-9]\+\)>/\1/g
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement