Skip to content

Instantly share code, notes, and snippets.

@u0d7i
Last active January 2, 2016 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save u0d7i/c03e34e57802d0b6347a to your computer and use it in GitHub Desktop.
Save u0d7i/c03e34e57802d0b6347a to your computer and use it in GitHub Desktop.
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