Reputation: 2531
I want to replace 'localhost' with an actual ip like '1.1.1.1' in every file in a directory including subfolders, plus I want it to log the filenames it changed. I'm having a difficult time doing this, what command should I use?
Upvotes: 1
Views: 925
Reputation: 7951
find /path/to/all/files -type f -exec sed -i 's/localhost/IP/g' {}\;
should work. Or you get an idea of how to make sed work on every file that find finds.
Upvotes: 1
Reputation: 284816
grep -r --files-with-matches localhost *|tee changed_files|xargs sed -i 's/localhost/1.1.1.1/g'
The files changed will be logged to changed_files
.
Upvotes: 2