Lindsay Lohan
Lindsay Lohan

Reputation: 81

Regex with wget?

I'm using wget to download some useful website:

wget -k -m -r -q -t 1 http://www.web.com/

but I want replace some bad words with my own choice (like Yahoo pipes regex)

Upvotes: 1

Views: 3013

Answers (2)

nfm
nfm

Reputation: 20667

If you want to regexp out words from within the page you are fetching with wget, you should pipe the output through sed.

For example:

wget -k -m -r -q -t 1 -O - http://www.web.com/ | sed 's/cat/dog/g' > output.html

Use the -O - flag to write the output to stdout, and the -q flag to make wget run in quiet mode.

Haven't got a shell atm to check my syntax but that should set you on the right path!

Upvotes: 3

Matthew Flaschen
Matthew Flaschen

Reputation: 284786

You can use sed -i.

find www.web.com -type f -exec sed -i 's/word1\|word2\|word3//ig' {} +

word1, word2, word3, etc. are the words to delete.

Upvotes: 1

Related Questions