- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: multi file substitution script
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
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
03-08-2004 09:49 PM
03-08-2004 09:49 PM
Does anybody can suggest me a shell script (or awk) to make automatic substitution in many files?
For Example:
I have many text files (shell script) with the command "SUIVI/command" and I want to change the string in EVERY file to make it become "SUIVI/xxx/command" or something similar.
Can anybody help me?
thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2004 09:54 PM
03-08-2004 09:54 PM
Re: multi file substitution script
Something like this,
for file in `file1 file2 ...`
do
sed s/SUIVI\/command/SUIVI\/xxx\/command/g > $file.new
mv $file $file.org
mv $file.new $file
done
I have not tried this though ;-)
-KarthiK S S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2004 10:06 PM
03-08-2004 10:06 PM
Re: multi file substitution script
The line
sed s/SUIVI\/command/SUIVI\/xxx\/command/g > $file.new
should be
sed "s/SUIVI\/command/SUIVI\/xxx\/command/g" $file > $file.new
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2004 10:07 PM
03-08-2004 10:07 PM
Re: multi file substitution script
#cat test | sed s/SUIVI\\/command/SUIVI\\/xxx\\/command/g > test.out
#mv test.out test
You could then put it in a loop :-
for file in test1 test2 test3
do
cat $file | sed s/SUIVI\\/command/SUIVI\\/xxx\\/command/g > $file.out
mv $file.out $file
done
Regards,
Dave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2004 10:20 PM
03-08-2004 10:20 PM
Re: multi file substitution script
perl -pi -e "s/SUIVI\/command/SUIVI\/xxx\/command" file*
The xxx could be replaced with a shell variable if you put this in a script and it's useful for you to do that. The file* is a list of files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2004 10:37 PM
03-08-2004 10:37 PM
Re: multi file substitution script
It gives me this error:
Substitution replacement not terminated at -e line 1.
What am I doing wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2004 10:40 PM
03-08-2004 10:40 PM
Re: multi file substitution script
The line should read
perl -pi -e "s/SUIVI\/command/SUIVI\/xxx\/command/" file*
I missed out that last "/" - sorry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2004 10:41 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2004 12:39 AM
03-09-2004 12:39 AM
Re: multi file substitution script
You resolved my problem.
I used the perl command and the sed command in automatic batch...
Now I submit points.
By!