Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    3

    Unanswered: 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

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •