Results 1 to 8 of 8
  1. #1

    unix scripting qustions on web pages


    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?

  2. #2
    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.

  3. #3
    Join Date
    Oct 2002
    "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

  4. #4
    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!

  5. #5
    Join Date
    Oct 2002
    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.

  6. #6
    note to self: don't use literal links.

  7. #7
    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

  8. #8
    'ls -R' should work in Linux too.Give it try.
    Thanks and Regards,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts