Oreilly sed & awk book to the rescue!
Quote:
|
Quote:
|
Code:
1 2 3 4 5 6 7 8 9 10 11 12 2. Creates a label to return to later 3. Appends the next line of input into the pattern space 4. Pattern starts with newline 5. Pattern to match 6. [^\n]* is a string which does not contain a newline. This limits the pattern to the last line in a multi-line pattern space. Otherwise the 'greedy matching' of * would try to match back to the second line in the pattern space. 7. Matches till the end of line 8. Negates previous expression 9. Substitutes 10. Due to 'greedy matching' .*\n matches everything up to the start of the last line in the pattern space. (The end of the last line in the pattern space is matched by $ not by \n ) 11. \1 is whatever is matched by the pattern in the ( ) i.e. Everything up to the last \n but not including it. 12. Returns to label |
Quote:
for the rest of the line, using printf (without \n) will concat lines |
All times are GMT -5. The time now is 10:06 AM. |