- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: replacing a value of the same variable in mult...
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp
Knowledge Base
Discussions
Forums
Discussions
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
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
04-20-2004 09:29 AM
04-20-2004 09:29 AM
file
....
XYZ=val
...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2004 09:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2004 09:49 AM
04-20-2004 09:49 AM
Re: replacing a value of the same variable in multiple files
TDIR=${TMPDIR:-/var/tmp}
T1=${TDIR}/X${$}_1.tmp
while [[ ${#} -ge 1 ]]
do
FNAME=${1}
shift
if [[ -w "${FNAME}" && -f "${FNAME}" ]]
then
sed s/XYZ=val/XYZ=newval/ < ${FNAME} > ${T1}
mv ${T1} ${FNAME}
fi
done
Use it like this:
fix.sh file1 file2 ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2004 10:28 AM
04-20-2004 10:28 AM
Re: replacing a value of the same variable in multiple files
perl -pi -e 's/XYZ=val/XYZ=new/g' *.c
This will replace the text in all files that end with ".c".
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2004 08:40 AM
04-21-2004 08:40 AM
Re: replacing a value of the same variable in multiple files
I used "\" in front of every "/", but got eorror "cannot be parsed"?
thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2004 08:56 AM
04-21-2004 08:56 AM
Re: replacing a value of the same variable in multiple files
sed "s|/d1/d2/d3/d4|/r1/r2/r3/r4|g" file.
Notice the double quotes and the pipe.