Results 1 to 8 of 8
-
06-02-2004, 09:14 AM #1Newbie
- Join Date
- Mar 2004
- Posts
- 6
unix scripting qustions on web pages
Hi,
I have a bunch of web pages structed within different directories on a site, since now I wish to move all of them to another site. I wish i can change all the URLs in HTML source code of these pages to another URL, which UNIX/linux COMMAND can do this. Or if I need a script, can you give a help on it?
-
06-02-2004, 11:07 AM #2Junior Guru Wannabe
- Join Date
- May 2004
- Posts
- 57
This is not a problem to create such scipt in e.g. php. But if the number of the pages is not overhelming, it will be probable faster to use an editor with suitable find/replace function and change all urls to relative so you will not face the same problem next time you move.
Sorry for not being able to help with the shell scripting.
____________________
My SEO related website: SEO
The source of plagiarism: The number of bright people exceeds the possible number of bright ideas.
-
06-02-2004, 11:33 AM #3Hail Eris !
- Join Date
- Oct 2002
- Location
- Canada
- Posts
- 3,103
"replace" is handy lil utility that comes with mysql
replace "from-string" "to-string" -- file1.html file2.html
or for all files in current directory:
replace "from-string" "to-string" -- *.html
note that it overwrites original files, so you should back them up before you try it
-
06-02-2004, 12:16 PM #4Newbie
- Join Date
- Mar 2004
- Posts
- 6
Thanks for your help! But this does not solve all my problems. Since I have a lot of files, so just use search and replace use html editor may take me a lot of time. i do not have mysql installed, is there any other way to do this?
Thansk a lot!
-
06-02-2004, 01:26 PM #5Hail Eris !
- Join Date
- Oct 2002
- Location
- Canada
- Posts
- 3,103
for f in `ls *.html` ; do mv $f $f.back ; sed 's/old_url/new_url/g' $f.back > $f ; done
That might work. Make test dir with only a few files to try it first.
-
06-02-2004, 04:19 PM #6Web Hosting Guru
- Join Date
- Nov 2003
- Posts
- 297
note to self: don't use literal links.
-
06-02-2004, 05:09 PM #7Newbie
- Join Date
- Mar 2004
- Posts
- 6
Sasha's script works!
Thanks a lot!
But can you tell me how to list all files including sub dirctories by using ls command in *LINUX*, I found -R option seems works only in Unix
-
06-03-2004, 05:20 AM #8Newbie
- Join Date
- May 2004
- Posts
- 11
'ls -R' should work in Linux too.Give it try.
Thanks and Regards,
Rose