Find all files excluding a single directory:
find . -path ./exclude-this -prune -o -type f -name '*.js' -print
Notes:
- The
-path ./exclude-this -prune -o
part ensures that the path./exclude-this
isn't included - The
-print
part ensures that the base directory of the excluded path isn't outputtet (this isn't needed if combining with-exec
)
Search and replace across files using a regular expression:
find . -type f -name '*.js' -exec sed -i '' -e 's/foo/bar/' {} \;
Notes:
- The
-i ''
in thesed
part of the command ensures existing files are replace without creating a backup. If you want the backup, just use-i
without the''
part