Extracting the last section of a file
Hi all,
I have a file which looks something like this: ########## some text text also includes empty lines ########## some more text ########## Basically all sections are separated by 10 hashes and I need to somehow only print all lines in the last section (the "some more text" part in the example above"). I tried all kind of things with sed and awk but I didn't find any way to identify the last "section". Any help is appreciated. Thanks, Sylaan |
This works for some versions of awk. Depends whether or not it supports multiple character record separators.
Code:
awk '{RS="##########";} END{print}' |
Actually, as the data ends with the separator the above will not work as the last entry is the empty data after the last separator.
Maybe try: Code:
awk '/[^[:space:]]/{out = $0}END{print out}' RS="##########" file |
Quote:
So, yours is definitely more robust. Good one, thx for speaking up. |
Code:
$ ruby -0777 -lne 'print $_.split(/##+/)[-1]' file |
Quote:
|
All times are GMT -5. The time now is 03:12 PM. |