Tuesday, December 21, 2010

Unix/Linux - Print out "string" between "match1" and "match2"

I was looking for a way to print text between "match1" and "match2", these two commands will achieve this:
 
sed -ne 's/.*\(match1.*match2\).*/\1/p'

egrep -o 'match1.*match2'

No comments: