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 a string in nth line maxmave Shell Programming and Scripting 1 06-04-2008 05:32 PM
problem in replacing a string ragavhere Shell Programming and Scripting 9 05-02-2008 09:02 AM
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 all files in a dir chiru_h Shell Programming and Scripting 3 07-25-2006 04:40 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-28-2007
mohan705 mohan705 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 134
Replacing string in files

Hi,
I Have 10 files ,I need replace $INPUT_LOCATION with $INPUT_LOCATION_upd .using sed command do it single file .How can change all files in single shot instead of doing individual file

sed -s'/old/new/g' file1

Thanks,
Mohan
  #2 (permalink)  
Old 08-28-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
GNU sed has an in-place string replacement flag -i

You can do

Code:
sed -i -e "s/$INPUT_LOCATION/&_upd/g" file1 file2 file3...
  #3 (permalink)  
Old 08-29-2007
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
using Perl:
Code:
perl -pi -e "s/\$INPUT_LOCATION\b/\$INPUT_LOCATION_upd/" file1 file2 file3
\b is for defining word boundary
Sponsored Links
Closed Thread

Bookmarks

Tags
perl, sed

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 03:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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