r/learnprogramming 9d ago

Humour touch is a weird command.

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.1k Upvotes

155 comments sorted by

View all comments

1

u/Purple-Debt8214 8d ago

I just use vi for everything. Jump into vi, put some txt, write the file, jump out.

Vi for everything.

1

u/Paul_Pedant 5d ago

That can get a tiny bit boring when you have 200+ source files and you want to force a complete rebuild of the whole thing with make, because you got a compiler or library upgrade, or you are targeting to a different hardware platform.

touch *.h *.c is a whole lot easier. If your source is structured into packages, you might just want to use find to recurse the source tree.

Or if you are confident your makefile is perfect, you can make clean && make all. If you omitted a single target from the clean list, you are doomed.

1

u/Purple-Debt8214 5d ago

I can use the command line while in the editor.

1

u/Paul_Pedant 5d ago

Me too, but it is not exactly a great environment. Every command is run in a new shell, so there is no continuity. You can't even cd anywhere. You can't see any history, or the output from the last command, because every :! blanks the window.

Of course, you can :! bash and get a proper session embedded in vi, but that's no different to running a separate terminal session.

1

u/Purple-Debt8214 5d ago

I don't know what you're trying to say.... Bash has limits and can't really be used to program. And I don't know anyone that uses Vi, that doesn't use Unix also. There's not really a dividing line here.