- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: 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
тАО02-09-2006 07:13 AM
тАО02-09-2006 07:13 AM
I have a nearly 120 html files in one server. Now we have migrated the files to a new server.
So I have written a redirect script which would redirect to the new server.
Now I would need to remove the contents of each html file and put the content of my redirect script in each of the HTML file.
Can anyone please tell me if I can remove the entire content of each file and put the content of my redirect script in each file.
I am not good in PERL or SHELL scripting.
Please help.
Thanks,
Pat
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2006 08:17 AM
тАО02-09-2006 08:17 AM
Re: script - help
sed 's/serverold/servernew/g' somefile.html > somenewfile.html
Rgds...Geoff
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2006 08:18 AM
тАО02-09-2006 08:18 AM
Re: script - help
perl -i -p -e 's{old/path}{new/path}g' *.html
HTH
-- Rod Hills
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2006 09:31 AM
тАО02-09-2006 09:31 AM
Re: script - help
I think I was not very clear on my requirement in my thread.
What I want to do is
1. remove the entire contents of existing .html files in my directory.
2. Copy the content of one of the files in another directory to all the .html files in my directory.
Hope this one is littl emore clear.
Please help me.
Thanks,
Pat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2006 09:36 AM
тАО02-09-2006 09:36 AM
Re: script - help
ls *.html | while read line
do
cat /dev/null > $line
done
This will keep the files in place but they will have 0 bytes in size.
To put something in a file
ls *.html | while read line
do
echo "This is the new stuff" > $line
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2006 09:46 AM
тАО02-09-2006 09:46 AM
Re: script - help
Based upon your last specification you could do this to overlay all of your files with a copy of another:
# find
The /tmp/overlay file will replace every file in
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2006 09:47 AM
тАО02-09-2006 09:47 AM
SolutionAre you saying, you want to keep all 120 html files, but make them empty? and then copy the contents of 1 file to all 120 html files?
cd /directoryof/existing/files
for i in `ls`
do
> $i
done
for i in `ls`
do
cat /directoryof/myredirectscript > $i
done
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2006 09:51 AM
тАО02-09-2006 09:51 AM
Re: script - help
While we are at it - make sure you have a good backup of those files...
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2006 09:52 AM
тАО02-09-2006 09:52 AM
Re: script - help
The first part in your solution really helps. I am able to create the empty files by doing that.
But in the second step, I have a file called "redirect". I need to copy the content of this file to all the .html files.
Thanks,
Pat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2006 10:46 AM
тАО02-09-2006 10:46 AM
Re: script - help
Unless I am misunderstanding you, you need to reexamine tha suggestion I offered using 'find' and 'xargs'. See the manpages for 'xargs' (particulary) to see how this technique works.
find
Regards!
...JRF...