2

I'm using this command to go through all files, directories and subdirectories to change any mentions of oldurl.com to newurl.org:

find . -type f -name '*.php' -exec sed -i 's|oldurl.com|newurl.org|g' {} +

It works fine, however, I need to exclude three sub-directories from ANY CHANGES: /cache, /archive and /etc as changing the urls with the above command in these paths breaks other scripts.

Haven't had much luck finding an answer... Is it even possible?

Many thanks for any suggestions/help.

4

1 回答 1

6

使用查找-not选项:

find . -type f -name '*.php' -not \( -path './etc/*' -o -path './cache/*' -o -path './archive/*'  \) -exec sed -i 's|oldurl.com|newurl.org|g' {} \;
于 2013-08-04T20:16:36.403 回答