I don't know the best way to do this. I wanted to change some files but I
wanted to keep the original timestamps. So I did it this way:
# get the timestamp
TIME_STRING=$(date -d "$(stat -c %y FILE)" +"%Y%m%d%H%M.%S")
make changes to FILE
# change the timestamp back to what it was before the change
touch -t $TIME_STRING FILE
My use was something like this:
for FILE in $(grep -l FOO) ; do
TIME_STRING=$(date -d "$(stat -c %y "$FILE")" +"%Y%m%d%H%M.%S")
perl -pi -e 's/FOO/BAR/' "$FILE"
touch -t $TIME_STRING "$FILE"
done
So how do you all do this kind of thing?
Mike