Find and replace recursive
January 17, 2018
Note: Do not run this command on a folder including a git repo - changes to .git could corrupt your get index.
For example to replace an IP on multiple files:
find /tmp/path -type f -exec sed -i '' 's/193.111.141.1/82.14.220.137/g' {} +
Multiple AMI's
find . -type f -name "variables.tf" -exec sed -i 's/ami-0e4168a4236171887/ami-00bec4c01ec9355e2/g' {} +
On BSD, MAC by passing an empty string to sed's -i args will create no backup
🔗perl -pi -e
perl -pi -e 's/replace_this/with_this/' files-*
This is useful when you don't want to change the file ending like in sed
that
adds an \n
ad the end of the file