Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2003
    Posts
    35

    Unanswered: sed with regular expression

    By using sed, how to express:
    a pattern is found, but don't do anything to this line
    e.g.: myfile has the following line and the pattern is "if"
    aaaa
    bbbb
    if
    cccc

    I want to get:

    echo aaaa
    echo bbbb
    if
    echo cccc

    Thanks for helping!

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: sed with regular expression

    cat myfile | sed '/if/!s/^/echo /g'

    HTH

    Sathyaram

Posting Permissions

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