Sed scripting...
Hi all,
I have a need for some search and replace type activity...
I need to change the urls in a bunch of files within a directory hierarchy.
I have been playing with sed to get the replacing done, and have come up
with the following:
sed -e 's/^.*:\///g' -e '/^\//!s/^/\//g' -e
'/$BASE_URL/!s/^/\/$BASE_URL/g' -e 's/^/$PRECEED_HTTP' "$filename" >
"$TMPFILE"
Where $BASE_URL is the 1st level url - i.e. www.debian.org.
$PRECEED_HTTP is the prefix that I want prepended to all urls - i.e.
http://127.0.0.1/
$filename is the file to modify and $TMPFILE is a temporary output file.
This works OK for lines that are just urls, but not (obviously) for lines
that urls embedded in them.
Any pointers?
Cheers,
Pete.
Reply to: