... replace a string recursively over several subdirectories

by zet — last modified May 03, 2013 07:02 AM

find ./ -type f -exec sed -i 's/string1/string2/g' {} \;

thanx to: John Jonas

 

Example for adding a stylesheet-link in the header of static html-files recursively:

find ./ -type f -exec sed -i "s/<HEAD>/<HEAD><link\ rel='stylesheet'\ type='text\/css'\ href='image_archive.css'>/g" {} \;

Filed under: ,