Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sed -nf
- # Prints the line containing a regular expression and next 4 lines
- # check if line matches regex
- /foo/{
- # set hold space to 4
- x
- s/.*/4/
- x
- # print line and restart
- p
- d
- }
- # if no match, check whether hold space is between 1 and 4
- x
- /[1-4]/{
- # decrement integer in hold space
- y/1234/0123/
- x
- # print line and restart
- p
- d
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement