![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 -n lines before and after | airman_ole | Shell Programming and Scripting | 5 | 07-05-2009 10:57 PM |
| To find the time difference between two lines of the same log file | satyakam | Shell Programming and Scripting | 2 | 04-30-2008 10:46 AM |
| How to delete specific lines at the same time | zanetti321 | UNIX for Advanced & Expert Users | 1 | 03-24-2008 07:00 AM |
| grep + lines after | Janus | Shell Programming and Scripting | 4 | 11-03-2006 05:56 PM |
| Joining 3 lines at a time | Sabari Nath S | Shell Programming and Scripting | 14 | 12-21-2005 01:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Grep two lines at a time
Hello;
i have a log file which had Invalid, error, missing words in it. I want to grab a line which matches either of the above words and one more line below the grepped line. Can this be done? I looked on other places on your forum, but there is nothing which is working. I tried following things: sed -n '/Invalid/ {p; n; p;}' r0035251.rpt <--- But this one does not have a case sensitive as well as multiple pattern matching. nawk is not available on my system grep -B <---- again not available. egrep -i command gives me the matched line, but I am not sure how to combine it with sed to be able to display the next line too! Can anyone help? Thanks Josh thanks |
|
||||
|
Quote:
Code:
awk 'tolower($0) ~ /error/ || tolower($0) ~ /invalid/ {print;getline;print}' file > a.log
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|