This sounds like an easily researched question. It isn't. I'm following the following highly recommended post on an Ubuntu Stack Exchange site that I happened to run across. But the suggestion doesn't work on Red Hat Enterprise Linux ES release 4. I would have expected it to, but it fails, as detailed below.
This is the suggestion: Specifically, the poster recommends
If you want to modify the file relative to its existing modification time instead, the following should do the trick:
touch -d "$(date -R -r filename) - 2 hours" filename
This does not work for me under Redhat. The minus sign is ignored and the time is set ahead two days just as if I'd entered
touch -d "$(date -R -r filename) + 2 hours" filename
$ ls -al test -rw-r----- 1 sc1478 dev 5 Oct 27 12:59 test $ touch -d "$(date -R -r test) - 8 days" test $ ls -al test -rw-r----- 1 sc1478 dev 5 Nov 4 2016 test $ touch -d "$(date -R -r test) + 8 days" test $ ls -al test -rw-r----- 1 sc1478 dev 5 Nov 12 2016 test
Whether I use a minus sign or a plus sign, the date is adjusted forward.
Is this a bug in some version of touch?
Is there another way to adjust a file's timestamp relative to its current timestamp?