0

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.

HippoMan
  • 595

1 Answers1

1

GNU touch uses --reference (-r) for this behaviour

ls -l ?
-rwx------ 1 roaima roaima 17894 Jun 23 12:32 x

touch --ref x y ls -l y -rw-r--r-- 1 roaima roaima 0 Jun 23 12:32 y

If you really need an implementation that honours -f I would suggest a shell script wrapper on top of a version that supports -r.

Chris Davies
  • 116,213
  • 16
  • 160
  • 287