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
Global replace with sed canary Shell Programming and Scripting 5 05-15-2008 07:19 AM
Perl: Global Search and replace epi8 Shell Programming and Scripting 3 05-06-2008 12:18 PM
Global Variable in awk... ZINGARO Shell Programming and Scripting 1 07-04-2007 10:07 AM
global replace with vi pixtond Shell Programming and Scripting 3 06-11-2004 01:54 AM
Global search ok...but replace? alan UNIX for Dummies Questions & Answers 0 03-25-2004 01:22 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-16-2005
Registered User
 

Join Date: Jul 2003
Location: London, England
Posts: 10
global replace...

Hi,

I have a dir containing many shell scripts. Each of these shell scripts state a database name (always the same), which I need to change to be a new database.

grep <database name> * brings back all the lines containing the database name. However, I need to change them to be something else.

Is there an easy way around this? or is it better to create a new dir area and use sed somehow?

Very new to all this? Can't find simple answer to match the simple query....

__________________
Regards

TOPCAT
Reply With Quote
Forum Sponsor
  #2  
Old 10-16-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
From the directory which has the scripts, run this.

Code:
for file in *
do
sed -e 's/EXISTING_DB_NAME/NEW_DB_NAME/g' $file > $file.tmp
mv $file.tmp $file 2> /dev/null
done
vino
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:37 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