Older versions of the touch
command offered a working -f
command-line option, which could be used as follows:
touch -f file1 file2
With this command, the modification time of file2
could be set to the same value as the modification time of file1
.
However, recent linux versions of the touch
command no longer honor the -f
option ... it's now a no-op.
Can anyone point me to a version of touch
which honors the -f
command-line option? Source code is fine.
I know that I can write program in C
or perl
or python
or some other language which will provide this functionality, but I'm hoping I can find a version of the actual touch
command itself which offers this -f
capability.
Thank you very much in advance.
PS: I don't care what language this requested version of touch
is written in, as long as it accepts the same command-line arguments as the standard touch
command and has a working -f
option. If no such thing exists, I'll end up writing it, probaby in python
, but I prefer not to "re-invent the wheel" if something like this already exists.
-r/--ref
is good enough for me. I was so focused on looking for-f
that I missed-r/--ref
in thetouch
man page. – HippoMan Sep 10 '22 at 15:40touch -r
(not--reference
) is standard, not GNU specific – Stéphane Chazelas Sep 10 '22 at 15:51touch -r x y
will copy both the mtime and atime. Usetouch -mr x y
if you only want to set the mtime, leaving the atime alone. – Stéphane Chazelas Sep 10 '22 at 15:54