Hi all,
Not been in here fo a while, hope someone can help. Basiclly, i have some HTML files that i need to correct errors in. I want to be able to do run a script with some parameters that will produce a new HTML file, with subtitutions. e.g.
commad will be ...
# fix-code.scr $1 $2 $3
where $1 is string to find, $2 is what to replace it with, and $3 is the name of the input file.
The purpose of this script is realy to correct HTML docs produced by web page editors that have supplied an incorrect link to a file or image using the 'file:///' method, they should insert the file reletive to the HTML doc, but this is not always the case.
Here is my script so far ...
#!/bin/sh
/usr/bin/sed s/$1/$2/g $3 > ./$3.sed
#
Now, this works IF i am just replacing a word, so this ...
# fix-code.scr file mile test.html
.. works and produces a file called test.html.sed. Cool!
The problem is with using longer lines that contain '/', and ':' I need a way to handle the input correctrly.
If I do this ...
# fix-code.scr file:////box/dir/dir/public_html/index.html ../index.html test.html
.. which should replace lines that read 'file:///bo..' with '../index.html'
but I get an error ....
sed: 1: "s/file:////box/dir/dir/ ...": bad flag in substitute command: '/'
Any idea's where i may be going wrong, or how my code needs to be altered are welcomed.
Regards JayBot! "Always know what you say, but don't always say what you know!"
Not been in here fo a while, hope someone can help. Basiclly, i have some HTML files that i need to correct errors in. I want to be able to do run a script with some parameters that will produce a new HTML file, with subtitutions. e.g.
commad will be ...
# fix-code.scr $1 $2 $3
where $1 is string to find, $2 is what to replace it with, and $3 is the name of the input file.
The purpose of this script is realy to correct HTML docs produced by web page editors that have supplied an incorrect link to a file or image using the 'file:///' method, they should insert the file reletive to the HTML doc, but this is not always the case.
Here is my script so far ...
#!/bin/sh
/usr/bin/sed s/$1/$2/g $3 > ./$3.sed
#
Now, this works IF i am just replacing a word, so this ...
# fix-code.scr file mile test.html
.. works and produces a file called test.html.sed. Cool!
The problem is with using longer lines that contain '/', and ':' I need a way to handle the input correctrly.
If I do this ...
# fix-code.scr file:////box/dir/dir/public_html/index.html ../index.html test.html
.. which should replace lines that read 'file:///bo..' with '../index.html'
but I get an error ....
sed: 1: "s/file:////box/dir/dir/ ...": bad flag in substitute command: '/'
Any idea's where i may be going wrong, or how my code needs to be altered are welcomed.
Regards JayBot! "Always know what you say, but don't always say what you know!"