If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > display lines after grep the pattern

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-24-06, 15:11
natlasr natlasr is offline
Registered User
 
Join Date: Mar 2004
Posts: 3
display lines after grep the pattern

Here is the example

The user id is xxxx and password is yyyy
123
234
000
987
The user id is xxxx and password is yyyy
333
555
The user id is xxxx and password is yyyy
888
999

I would like to look for first occurence of xxxx, As soon as I find the xxxx and
display 4th line, which is 987

Thanks
Reply With Quote
  #2 (permalink)  
Old 04-25-06, 05:54
davidcollins001 davidcollins001 is offline
Registered User
 
Join Date: Feb 2006
Posts: 15
I am new to this, but I thought that I would post this as it may help you.

# print the line immediately before a regexp, but not the line
# containing the regexp
sed -n '/regexp/{g;1!p;};h'

(http://www.student.northpark.edu/pem...d/sed1line.txt)

It's not exactly what you are after, but it might be a good starting place
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On