Contact our honeypot department if you are desperate to get blacklisted.

Wednesday, November 18, 2009

Recursively Search & Replace with grep and sed

The following tidbit recursively searches the current directory for files containing a string, and replaces the string, in place, with a new string,

grep -rl original ./* | xargs sed -i 's/original/replacement/g' 
By default sed and vi will only replace the first instance of a string on a line.  The /g will ensure that all instances of on every line is replaced.