Archive for December, 2009

recursive search and replace with grep and sed

Thursday, December 3rd, 2009

grep will do a first find and return the matched file names
xargs will pass each file name with its path to sed
and obviously sed will edit inline and replace the contents

grep -rl “oldword” ./  | xargs sed -i  ’s/oldword/newword/’