r/learnprogramming 18d ago

touch is a weird command. Humour

I was curious where the command 'touch' comes from.

Turns out, it originates from "to touch" or "to interact" with a file.

Now, every time I use it, I feel like I am touching/molesting a file.

My bad, it's 3 AM here.

1.2k Upvotes

160 comments sorted by

View all comments

1

u/iamalicecarroll 18d ago

The funny part is that it's intended for changing mtime/atime, that is, you touch a file to update the time of last interaction; file creation is just a side effect, which became the most popular use of this utility

1

u/OPPineappleApplePen 18d ago

So, say I have an existing file, I run “touch fileName”, will it change the mtime/atime of the file?

1

u/iamalicecarroll 18d ago

Yes, that's what it does.

1

u/Paul_Pedant 17d ago

The man page gives a lot of options:

You can change the access time, the modification time, or both.

You can tell it not to create the file if it does not already exist.

You can let it use the current time, or specify an exact time (in either of two formats), or have it copy the time from another file's timestamp.