The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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-29-2007 01:27 AM
Problem replacing the string Viken Shell Programming and Scripting 2 03-18-2007 06:38 PM
replacing char with string phani_sree High Level Programming 1 11-20-2006 08:57 AM
string replacing priya_9patil Shell Programming and Scripting 1 11-03-2006 12:05 PM
replacing a string in a file with command line parameter chiru_h Shell Programming and Scripting 5 08-03-2006 09:34 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-04-2008
maxmave maxmave is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 21
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
  #2 (permalink)  
Old 06-04-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
This site has great sed one-liners.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0