![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| grep for a particular pattern and remove few lines above top and bottom of the patter | fed.linuxgossip | Shell Programming and Scripting | 17 | 07-25-2008 09:29 AM |
| grep required pattern and next 2 or 3 lines | cvvsnm | UNIX for Dummies Questions & Answers | 3 | 02-01-2008 05:20 AM |
| Search file for pattern and grab some lines before pattern | frustrated1 | Shell Programming and Scripting | 2 | 12-22-2005 03:41 PM |
| grep - to exclude lines beginning with pattern | frustrated1 | Shell Programming and Scripting | 2 | 08-29-2005 08:18 AM |
| Need ls to show number of lines in each file | GMMike | UNIX for Dummies Questions & Answers | 1 | 11-19-2004 05:53 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
grep to show lines only after pattern
When i grep for a pattern the search results comes up with matching lines(some before the pattern and some after)...how can i limit the search so that it shows only the lines after the pattern specified
|
|
||||
|
hmm..
This wont help..
Print NUM lines of trailing context after matching lines.. Instead of lines I need pattern Eg: Say i search for a pattern abc...the result i get is hdhd fhfhfh abc hdh jdhf I want the result to be hdh jdhf I went through the man page for grep and couldnt find any option which would help me accomplish the above result :-( |
|
|||||
|
You might want to look into the -E flag to see if it helps you. Off the top of my head, I can say, you could use sed.
Code:
sed -n -e "s/.*abc \(hdh jdhf\)/\1/p" input.txt |
|
||||
|
Hi wannalearn, I need that "awk" script that you used to print 'n' no of lines below the matching pattern including that line also.
grep -A<n> "pattern" <file> --> will do the job, though I need an awk script for this. Please provide me. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|