Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Preserve file timestamp in multifile string replace
-I to grep ignores binary files,
@ in sed works as separator for strings with /
-r in touch uses existing file timestap as a reference
$ grep -IR aaaa /somepath/ | awk -F: '{print $1}' | while read line; do touch -r $line /tmp/timeref; sed -i 's@aaaa@bbbb@' $line; touch -r /tmp/timeref $line; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.