Skip to content

Instantly share code, notes, and snippets.

@thomasschuiki
Created November 11, 2021 08:40
Show Gist options
  • Save thomasschuiki/ecb0b528413132ad9112ccf3ae743ab2 to your computer and use it in GitHub Desktop.
Save thomasschuiki/ecb0b528413132ad9112ccf3ae743ab2 to your computer and use it in GitHub Desktop.
Replace text in files with sed and find
# replace <word> with <replace> in all files in current directory (creates backup files)
sed -i.bak -- 's/<word>/<replace>/g' ./*
# replace <word> with <replace> in certain files recursivly (creates backup files)
find ./folder -type f -name "*.ext" -exec sed -i.bak -- 's/<word>/<replace>/g' {} +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment