Results 1 to 2 of 2
As this thread has been closed for some obscure reason, I'll just have to start a new one to post a slight improvement on using sed to print the last ...
- 02-10-2009 #1Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
Grep last pattern output
As this thread has been closed for some obscure reason, I'll just have to start a new one to post a slight improvement on using sed to print the last occurrence of a pattern in a file:
Code:sed -n '/pattern/x; ${x;p;}' file
- 02-10-2009 #2Just Joined!
- Join Date
- Jan 2009
- Location
- Halifax, NS
- Posts
- 19
If the OP from the previous thread was also wondering how to match the first pattern.
You can do
Could come in handy, it just did for me.Code:grep 'pattern' file | head -1


Reply With Quote