Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change word in shell script

Status
Not open for further replies.

Johuak

IS-IT--Management
Jul 31, 2007
21
US
Hello,
I have on script directory when i have all my scripts. There are about 50 different scripts and all of them have my manager's email address somewhere inside that script. Now i got new manager, so i have to change that email address.

Is there anyway i can cahnge that name without opening script.
 
Hi

For example if your script file names have no space ( ) :
Code:
for f in *.sh; do
  sed -i 's/old@example\.com/old@example.net/' "$f"
done
Needs newer GNU [tt]sed[/tt] implementation which supports in-place editing.

But better modify them all once for ever. Make all 50 scripts to get the mail address from the same file, let us say, config.txt :
Code:
managermail='manager@example.org'
Code:
#!/bin/sh

. config.txt

echo 'Hello boss' | mail -s 'Hello' "$managermail"

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top