![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| replacing new lines in all files of a directory containing old lines | rooster005 | Shell Programming and Scripting | 1 | 03-25-2008 03:38 PM |
| How to delete first 5 lines and last five lines in all text files | ragavendran31 | Shell Programming and Scripting | 10 | 02-21-2008 07:58 AM |
| How to count lines - ignoring blank lines and commented lines | kthatch | UNIX for Dummies Questions & Answers | 6 | 05-25-2007 02:21 AM |
| need help appending lines/combining lines within a file... | mr_manny | Shell Programming and Scripting | 2 | 01-06-2006 06:45 PM |
| delete blank lines or lines with spaces only | vascobrito | UNIX for Dummies Questions & Answers | 3 | 01-13-2004 07:36 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
X num of lines before and after
I have a slew of files for historical reference.
Each file has a unique line in the file, such as "Today's datetime is:" Each file also contains a unique set of characters on line X, such as "DMX Info." This line number will be different each time a new file is generated. So, for one file, it might be line 100, whereas the next file might be line 120. The important info I'd like is always two lines below line X above, but not unique enough to simply grep on by itself. It's called "High Value" and there are several lines like this in each file. QUESTION: How do I grep for "Today's datetime is" AND two lines below line X? I don't care if line X is printed. It's the line two lines below that I'm looking for. THANKS! |
|
||||
|
That almost works, but it appears to only scan one file, whereas I'm trying to scan hundreds. Also, anyway to omit printing the first line after line X, and only print the second.
This is very helpful, so thanks guys (or gals). Last edited by jjp; 09-15-2008 at 02:20 PM.. Reason: incorrect |
|
||||
|
There we go. That works, but it appears the 'exit' won't look in all files. For some reason it only scans one. If I omit the 'exit', it works perfectly.
Thanks. Shell scripting is not my strong point, but I need to get moving on it. Thanks again! ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|