Originally Posted by
ghostdog74
Code:
find . -type f -name "file" -exec awk '{gsub(/replace/,"new")}1' "{}" > temp \; -exec mv temp "{}" \;
That will only work if there's at most one matching file. It's equivalent to
Code:
find . -type f -name "file" -exec awk '{gsub(/replace/,"new")}1' "{}" \; -exec mv temp "{}" \; > temp
This'll edit the files using awk.
Code:
find . -type f -name "file" -exec awk '{gsub(/replace/,"new"); print > FILENAME}' {} +
Oh and to the OP, for learning bash, stay away from the bash guides at tldp.org. Read the bash guide that nothingspecial posted. It's the only one that teaches good practice.
Bookmarks