Results 1 to 1 of 1
Hello all,
In my current project I need to extract a section of text from the bottom of a file till a pattern is match, for example,
cat data
Code:
...
- 03-03-2009 #1Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
Better way to match a section of a file based on regular expression
Hello all,
In my current project I need to extract a section of text from the bottom of a file till a pattern is match, for example,
cat data
I need to extract the text beginning with def@domain.net (the From line will be used as ending pattern and it can be any email address). What I came up with so far is:Code:old old data old data From: abc@domain.com something else more text ... From: def@domain.net some data more data ...
tac data | sed '/From.*@.*/q' | tac
This works well and meets my need but I wonder if there are other (more elegant) solutions to this problem.
Thanks for helping.


Reply With Quote