The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replacing string in files mohan705 Shell Programming and Scripting 2 08-28-2007 10:27 PM
Problem replacing the string Viken Shell Programming and Scripting 2 03-18-2007 03:38 PM
replacing char with string phani_sree High Level Programming 1 11-20-2006 05:57 AM
string replacing priya_9patil Shell Programming and Scripting 1 11-03-2006 09:05 AM
replacing a string in a file with command line parameter chiru_h Shell Programming and Scripting 5 08-03-2006 06:34 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 06-04-2008
Registered User
 

Join Date: Apr 2008
Posts: 20
Replacing a string in nth line

Hello All,

How to replace a string in nth line of a file using sed or awk.

For Ex: test.txt

Line 1 : TEST1 TEST2 TEST3
Line 2 : TEST1 TEST2 TEST3 TEST4
Line 3 : TEST1 TEST2 TEST3 TEST5
Line 4 : TEST1 TEST2 TEST3 TEST6
Line 5 : TEST1 TEST2 TEST3 TEST7

i want to go to 4th line of a file and replace the word TEST2 in that line with the word DEV2.

Note : this is not a homework. just need some ideas in SED or AWK

Thanks

Rahul
Reply With Quote
Forum Sponsor
  #2  
Old 06-04-2008
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 567
This site has great sed one-liners.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0