The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-24-2008
santosham santosham is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 17
overwriting a line in text file

I have a text file with following content (3 lines)

filename : output.txt

first line:12/12/2008
second line:12/12/2008
third line:Y


I would like to know how we can replace 'Y' with 'N' in the 3rd line keeping 1st and 2nd lines same as what it was before.

I tried using cat output.txt |sed -e 's/third line:Y/third line:Y/' , but in this case it writes the output to some other file and we have to replace that old file with new file.

Do we have a way to do this without replacing the old file with new file after using sed command or can we do this any command other than sed?

Last edited by santosham; 06-24-2008 at 12:16 PM..