Command line

Various command line wizardry:

Search and replace text recursively in all files in a directory and its subdirectories:


find . -type f -name '*.txt' -exec sed -i '' s/this/that/g {} +

This assumes you want to replace 'this' with 'that' in all files with the extension .txt. It is case-sensitive. The last 'g' means to do it more than once per line if needed ("globally").


Keywords: find/replace folder subfolder subfolders subdirectory