I already have a file named param.txt with some data on it. If I run touch param.txt in the same folder will my data get lost?

  • 1
    Updates the timestamp. First line of man page Update the access and modification times of each FILE to the current time. – 123 Feb 28 '18 at 15:41

The contents of the file will not be lost, and it won't even be modified. The only thing that happens when you run touch on an already existing file is that the file's access and modification timestamps are updated to the current time.

This is explained in the touch manual (man touch).

  • 6
    and this is the primary (or original) purpose of touch. That it creates the file if not already existing is secondary. – user4556274 Feb 28 '18 at 15:43
  • 1
    @user4556274 Hmm... The earliest reference I can find to touch is in Bell Labs V7 Unix, in which it did create the file unless -c was used. But you may not have implied that it couldn't create files from the start? – Kusalananda Feb 28 '18 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.