- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: shell script help!!
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
Discussions
Discussions
Forums
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
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
тАО05-10-2002 08:10 PM
тАО05-10-2002 08:10 PM
shell script help!!
about 500 files exists
and I have to insert strings to those files..
How can I replace the strings all files..
See attached files..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2002 08:29 PM
тАО05-10-2002 08:29 PM
Re: shell script help!!
Something like this...
(NOTE, I would reccommend testing before running. I am operating off of memory, which is falible.)
for file in `ls *.db`
do
sed '/\@ IN SOA/{x;s/^\$TTL 86400/;G;}' $file > $file.new
done
If you are brave, you could tuck in a move statement to replace the old files with the new one in the for loop. I would suggest making sure that the output is what you expect before doing so, however.
Like I said before. I am doing this from memory, so test the sed command against a sample file and redirect the output someplace neutral before running the command against all 500 files.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2002 08:48 PM
тАО05-10-2002 08:48 PM
Re: shell script help!!
sed '/\@ IN SOA/{x;s/^/\$TTL 86400/;G;}' $file > $file.new
A quick Google check confirms that the syntax should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2002 10:29 PM
тАО05-10-2002 10:29 PM
Re: shell script help!!
I would use the same for loop
but I would use a combination of sed and tr :
for inputfile in `ls *.txt`
do
sed 's/\@ IN SOA/\$TTL 86400=&/g' ${inputfile} | tr "=" "\n" > ${inputfile}.out
done
Thanks,
Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2002 11:29 PM
тАО05-10-2002 11:29 PM