- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: shell script question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2003 06:38 AM
02-20-2003 06:38 AM
I work on HPUX
I want to replace on all
scripts in the machine
the expression :
" $EXPHOME/dir/ "
with this expression :
" $EXPDIR "
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2003 06:46 AM
02-20-2003 06:46 AM
Re: shell script question
Thanks
RZ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2003 06:50 AM
02-20-2003 06:50 AM
Re: shell script question
for file in `cat listofscripts`
do
sed 's/$EXPHOME\/dir\//$EXPDIR/' $file > $file.out
mv $file.out $file
done
might do it (though I expect that's pretty crude - I didn't test anything).
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2003 07:13 AM
02-20-2003 07:13 AM
Solutionyou'll have to change INI_DIR to "/", of course...
the original files with extension $SHELL_EXT will be backed up to .bak before the change is made.
#cat test.sh
#!/usr/bin/ksh
INI_DIR=.
SHELL_EXT=".sh"
echo $0
for i in `find $INI_DIR -name "*$SHELL_EXT"|grep -v $0`
do
sed -e 's|$EXPHOME/dir/|$EXPDIR|g' $i >/tmp/tmp_file
j=`basename $i $SHELL_EXT`.bak
mv $i $j
mv /tmp/tmp_file $i
done
#./test.sh
./test.sh
find: cannot open ./.AgentSockets
find: cannot open ./DBI-1.18
#diff test2.bak test2.sh
1c1
< $EXPHOME/dir/
---
> $EXPDIR
Cheers,
FiX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2003 08:05 AM
02-20-2003 08:05 AM
Re: shell script question
Use perl to do an in-line replace:
perl -i -pe '{s+\$EXPHOME/dir/+\$EXPDIR+g}' filename
Put a loop around this to do it on all files.
rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2003 11:34 AM
02-20-2003 11:34 AM
Re: shell script question
It actually uses sed, just like the guys in the posts above. It's just got a little front end.
You'll need to update the perl location, and its pretty well documented. Buzz back if you have any questions.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2003 06:34 PM
02-20-2003 06:34 PM
Re: shell script question
# ls -1 |while read i
do
cp $i $i.bak
sed -e "s/\$EXPHOME\/dir\//\$EXPDIR/" $i.bak > $i
done