Quote:
Originally Posted by paullanders
Works perfectly. Thanks so much!
I'm not familiar with the curly brackets and N in sed.
|
Well, the first set of {} specifies a quantifier, i.e. sed will only match digits if there are exactly two of them.
The second pair of {} simply groups the commands 'N' and 's', i.e. only if a match occurs will those two commands be executed. Normally, one would have to escape the first set of {}. However, the '-r' option activates sed's extended RegEx mechanism. Therefore it can determine the meaning of {} by context.
The 'N' command simply reads the next line
and appends it to the pattern-buffer. E.g., this is how your pattern-buffer looks like before and after 'N' is executed:
Code:
# before 'N' is executed
12
# afeter 'N' is executed
12\nThis is a line of text
Hope this clears things up a bit.
If you are interested in more details, here is one of the very best online tutorials on 'sed':
http://www.grymoire.com/Unix/Sed.html