Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all, I have a set of lines as ahown below: Leon went to school Leon came back from school.. Leon had dinner... I have to replace the line containing ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2010
    Posts
    3

    [SOLVED] Using sed Replace line containing particular string by a single string


    Hi all,
    I have a set of lines as ahown below:



    Leon went to school
    Leon came back from school..
    Leon had dinner...



    I have to replace the line containing "dinner" by a single string LUNCH...
    can anyone hint me how to do using sed command....

  2. #2
    Just Joined!
    Join Date
    Oct 2010
    Posts
    6

    Replace line using sed

    Code:
    echo "Leon went to school
    Leon came back from school..
    Leon had dinner..." | sed '/dinner/ c\LUNCH'

  3. #3
    Just Joined!
    Join Date
    Oct 2010
    Posts
    3
    great..... it worked.... thank u

Posting Permissions

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