Feb 14, 2012 #1 jdhahbi Technical User Oct 7, 2009 24 US Hi how to print line matching a pattern and line immediately above it? thanks joseph
Feb 14, 2012 1 #2 PHV MIS Nov 8, 2002 53,708 FR Something like this ? Code: awk '/pattern/{print x"\n"$0}{x=$0}' /path/to/input Hope This Helps, PH. FAQ219-2884 FAQ181-2886 Upvote 0 Downvote
Something like this ? Code: awk '/pattern/{print x"\n"$0}{x=$0}' /path/to/input Hope This Helps, PH. FAQ219-2884 FAQ181-2886
Feb 14, 2012 1 #3 blarneyme MIS Jun 22, 2009 160 US Code: sed -n '/mypattern/{x;p;x;p;};h' myfile Upvote 0 Downvote