My task is to take a directory of website files, including html, css, and non-text image files, and change all image paths from relative paths to a universal cdn path. This is on a mac.
My starting point is something like this:
sed -i '' 's/old_link/new_link/g' *
but I want it to act only on css,html files, and to recurse through any subdirectories.
thanks
Try using find
. Soemthing like:
find . -name *css -exec sed -i '' 's/old_link/new_link/g' {} ';'
will find all the css files in your current directory and below it and pass each one to sed. The {}
stand in for the name (and location) of each file that find finds. Don't omit the quote marks around the final ;
Then repeat for html files.
As ever, for the finer points of syntax consult man, or google for the find documentation.