![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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 |
||||
| Google The UNIX and Linux Forums |