LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Batch search and replace (https://www.linuxquestions.org/questions/linux-newbie-8/batch-search-and-replace-288804/)

devilkin 02-11-2005 12:58 AM

Batch search and replace
 
Someone has given me a website that has a large amount of absolute links on it (200+ pages) and I'm looking for a way to do a search and replace on all files to replace these absolute links with relative ones...

Can anyone suggest a start point for me? I do know a little bash scripting and a little C++ but i haven't the slightest idea where to start...

Padma 02-11-2005 09:28 AM

Since html pages are nothing but text files, you might be able to do what you want with a shell script using 'sed' to make the changes.

Something like

sed -e 's/\/absolute\/directory/..\/directory/g' inputfile.html >outputfile.html

Google for 'sed', and/or do a 'man sed' on your system.

devilkin 02-14-2005 02:39 AM

Thanks for that Padma, i got it :D

The more i use linux the more i love it


All times are GMT -5. The time now is 07:46 AM.