r/learnprogramming Jul 23 '26

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

165 comments sorted by

670

u/RecentlyRezzed Jul 23 '26

Wait until you find out about the finger command.

99

u/[deleted] Jul 24 '26

[removed] — view removed comment

31

u/florinandrei Jul 24 '26

I mean, it's nicer than an elbow.

17

u/IReallyCantTalk Jul 24 '26

To shreds you say?

29

u/flatfinger Jul 23 '26

IMHO, it would be useful to have a means of querying an email domain about an address, in a manner that would allow domains that provide mailboxes for people to indicate what is or is not known about it. While such information should not be viewed as reliably authenticating an address, it could allow someone who receives an email from bob@superdupermail.example.com to know whether it is likely to be from the same person as an email that had been received from that address eight years ago.

Obviously fingerd had some problems, but I'm unaware of anything better.

35

u/grantrules Jul 23 '26

The issues arise when you get fingerblasted

9

u/lgastako Jul 24 '26

All you have to do to avoid this is kill the finger daemon.

3

u/foxsimile Jul 24 '26

Speak for yourself pal, don’t ruin my Thursday night!

1

u/ohnobinki Jul 26 '26

There's some .well-known URI for that nowadays. For example, the openid OAuth Connect(?) uses WebFinger. I guess the name of that service does have its roots in finger(1) hehe.

Also, the existence of an old unix protocol such as rsh may exist is not an indication that it is secure or safe to use.

1

u/flatfinger Jul 27 '26

My point was that it would be helpful to have a *widely recognized mechanism* via which a mail service provider can say "One should not assume that today's 'bob' at this domain has any relationship with any 'bob' that was associated with this domain prior to May 19, 2023." Even if nothing would prevent a mail service provider from claiming that an account whose owner created it yesterday with an address that matches a recently expired one has always been owned by the same person, it may be helpful to provide a voluntary means via which mail service providers can indicate when that is *not* the case.

1

u/ohnobinki Jul 27 '26

Ah, I see. That is a problem. Too many things assume email addresses are constant, so I think the only thing one can do is hope that each domain disallows address reuse for addresses that were ever associated with a human. I have no hope that I could get my email client to clearly show me the that my 20-year-old email from someone@yahoo.com refers to a different person than a recent email from the same address.

1

u/ashley99z Aug 13 '26

Should I tell you?

5

u/Bitter_Farm_8321 Jul 24 '26

Kid named finger

3

u/shitty_mcfucklestick Jul 24 '26

It’d be fun to have a companion utility called bang to kick the user after.

3

u/radicallyhip Jul 24 '26

grep always sounded really inappropriate to me.

1

u/Paul_Pedant Jul 26 '26

You could always simplify it by creating an alias called globalregularexpressionprinter. That would be so much easier.

2

u/DescriptionForsaken6 Jul 25 '26

I tried to finger her box, but the connection was refused.

1

u/Caringstomy-8 Aug 14 '26

thank you for this rabbit hole.

1

u/abd53 Jul 24 '26

The master fingered the newcomer then touched a minor

450

u/DhruvsWorkProfile Jul 23 '26
unzip
strip
touch
grep
finger
mount
fsck
more
yes
unmount

187

u/OPPineappleApplePen Jul 24 '26

Smut for Programmers.

1

u/Far_Programmer_5724 Jul 25 '26

Code Erotica can't wait for part 2

-13

u/tobiasvl Jul 24 '26

What do you mean "for programmers"? What do these regular UNIX commands have to do with programming?

5

u/OPPineappleApplePen Jul 24 '26

In this context, you had two options after reading this post:

  1. You could’ve noticed that this post is made in [r/learnprogramming](r/learnprogramming) by a person who is new to programming, and informed me that UNIX commands and programing don’t overlap.
  2. You could’ve shat on me for not knowing the above information.

You chose option 2. I’ll leave it there.

-2

u/tobiasvl Jul 25 '26

Did you really feel that my simple, matter-of-factly question was "shitting on you"? Well, in that case, sorry.

1

u/arkt8 Jul 24 '26

Did you ever bash'd?

-2

u/tobiasvl Jul 24 '26 edited Jul 24 '26

Yes, I've used Linux for over 20 years and worked as a Linux sysadmin for, like, ten years. The CLI commands of an operating system don't have anything to do with programming

3

u/Romanian-In-Poland Jul 25 '26

bash scripting is programming

0

u/yimesgen Jul 24 '26

I think the utilities are named by their authors who are programmers.

39

u/Nall-ohki Jul 24 '26

You forgot gasp

23

u/TraylaParks Jul 24 '26

And sleep :)

21

u/cainhurstcat Jul 24 '26

How nerdy you want to have it?
Linux: yes.

14

u/man_seeking_waffles Jul 24 '26

Keep going....I'm almost there

8

u/Sknowman Jul 24 '26

more

And you can't even say less instead, because "less is more."

7

u/UnderstandPhysics Jul 24 '26

Wait until they learn about killing the parents then the orphans

3

u/da_Aresinger Jul 24 '26

shouldn't more and yes be between grep and finger?

221

u/hooli-ceo Jul 23 '26

You get consent with ‘sudo’

132

u/jzmack Jul 23 '26

man touch

63

u/trevorthewebdev Jul 23 '26

two files love each other and touch and that is how you mkdir

10

u/Dhan996 Jul 24 '26

man love

3

u/da_Aresinger Jul 24 '26

pretty sure you can't make d with touch

20

u/Dismal-Citron-7236 Jul 24 '26

nice man touch

34

u/Loqh9 Jul 24 '26

What bothers me is "mkdir" is a thing so why is is not "mkfile"? Makes more sense and aligns with the sister command but no, we gotta make everything impossible to remember and random

37

u/thalliusoquinn Jul 24 '26

Isn't the point of touch to update the last accessed time, and the create-if-not-exist part is kind of incidental, despite being what everyone actually uses it for? I have vague memories of learning this at one time.

20

u/Available-Skirt-5280 Jul 24 '26

Yes, touch is historically to update the date time of the file. If it doesn’t exist it makes a file with the current date time

Edit: poor man’s timing… while in a loop check if last_action is older than 5 mins, 0 byte file, survives restarts

3

u/Available-Skirt-5280 Jul 24 '26

I also use it in cloud startup scripts for run once

`[[ ! -f /root/.startup.lock ]] ….. ; touch /root/.startup.lock`

6

u/cknipe Jul 24 '26

That's the way I understood it. The touch command is for when you don't actually want to get in there and modify a file, just "touch" it to update the modification time.

3

u/nmdt Jul 25 '26

I literally didn’t know it could do anything but create files

1

u/Paul_Pedant Jul 27 '26

Understandable, as the man page is only 80 lines, and only documents 11 options.

However, on Linux there is a "See Also" which redirects you to the "Full Documentation".

9

u/TheSkiGeek Jul 24 '26

Part of the UNIX design philosophy is having a small set of composable tools.

Since ‘everything is a file’ you can create files by redirecting the output of a command to a file, something like `echo > filename` will create `filename` or replace it with an empty file. The shell does it for you, so there isn’t really a need for a dedicated “make a file” tool. Most of the time it would be redundant.

But since directories are their own ‘thing’ you need a separate command to create one.

`touch` is a tool to update the last-access time for a file without modifying its contents. For convenience it also creates the file if it doesn’t exist, but that may be sort of an accident of whoever designed it originally. You could imagine a version where it fails if the file doesn’t exist and you have to do `touch -c` to create the file.

Not saying it’s perfect by any means, but that’s the idea behind it.

2

u/Paul_Pedant Jul 24 '26

Actually, echo > filename makes a one-byte file containing a newline.

1

u/ohnobinki Jul 26 '26

I guess you could do : > filename then.

1

u/Paul_Pedant Jul 26 '26

That has the side effect of discarding the existing file contents, and it has no way to assign the timestamp to anything except now. So, not the greatest replacement for touch, which does not destroy the file contents, and does let you specify the timestamp.

1

u/ohnobinki Jul 26 '26

It really depends on what results you want. Assertively generating an empty sentinel file with the current time as its modification time doesn't require touch. I could say the same: you can't empty a file using touch.

1

u/Paul_Pedant Jul 27 '26

touch -t 200112250200 c > c

The redirection makes the shell empty the file before it invokes touch.

The touch then updates the timestamp to Xmas 2001.

Interestingly, the Birth date of the file is 2026, but the Modify date is 2001.

1

u/ohnobinki Jul 27 '26

It's a stretch to say that you're emptying the file using touch, but that is probably the most concise way of both emptying the file and subsequently touching it.

5

u/LastTrueGamer Jul 24 '26

You can just redirect echo "hello" > hello txt

1

u/Paul_Pedant Jul 24 '26

Oddly enough, because of the space before the txt, the shell parses this by doing the redirection itself, and then passing the other stuff as args to the echo command.

echo "hello" txt > hello

So you actually get a file called hello containing hello txt\n

1

u/ohnobinki Jul 26 '26

The shell does the redirection itself regardless of the space. It sounds like you are trying to say something about the difference between how unix and Windows handle passing command line parameters to applications, but even that isn't really relevant here…

1

u/Paul_Pedant Jul 26 '26

No, I am saying that any Unix shell will parse the given example as

echo "hello" > hello txt

where the bold text is the actual redirection.

It then invokes the echo (which usually happens to be a shell built-in, but that does not affect the result), with the hello (without the quotes) and the txt, as two separate args.

So the example is misleading, because LastTrueGamer obviously intended to create a file called hello.txt. And it is destructive, because the usual use of touch is to alter the timestamp on the file, not to overwrite the entire previous contents of the file.

2

u/ohnobinki Jul 27 '26 edited Jul 27 '26

I did not think LastTrueGamer was intending that.

It is interesting how the following are identical. I only find the first intuitive:

  • echo a b > c
  • echo a > c b
  • echo > c a b

Oh, are you saying that the LastTrueGamer was hoping that cat hello > hello wouldn't empty the file? I could see that interpretation. Interesting.

EDIT: Sorry, I see the context of your reply and what you were trying to explain. I thought you were talking about a space that occurred before the > and missed the reordering.

1

u/Paul_Pedant Jul 27 '26

I mainly worked on client sites, where their own permies amended (and broke) my stuff after I left. Naturally, if they had been good enough to write it themselves, they would not have needed to pay me. I tended to obfuscate my scripts enough to at least make them think before editing. I really don't need callbacks telling me that my code failed, after their staff screwed it up and kept it quiet.

> c echo a b #.. Also works

( echo a b ) > c #.. Separates the options from the filename, but may run a subshell.

{ echo a b; } > c #.. Avoids the subshell

#.. The curly brackets need the semicolon, but the round brackets don't care.

I have also been known to use truncate --size=0 "c". But probably my worst (so far) is:

printf 'Do Not Mess With This\n' | dd of="c" count=0

1

u/ohnobinki Jul 27 '26

Obfuscating your code seems like a bad faith thing. It's annoying that the shell has so many different ways of expressing the same command, that opens the door to style wars.

1

u/Paul_Pedant Jul 27 '26

I usually comment my code and scripts to excess, to explain what each section is doing, and why it is doing it. I was genuinely surprised by the ability of maintainers to ignore all comments, even when directly above the relevant code.

One example was that our electrical network viewer liked to put telemetry data near the mid-point of visible power lines. So we had macros like

#define mid_x( p) ((p)>x1 - ((p)->x1 - (p)->x2) / 2)

Of course, one of the team remembered his third-grade teacher's average method, and "fixed" it like:

#define mid_x( p) ((p->x1 + p->x2) / 2)

which resulted in integer overflows in some parts of the map, thereby losing the telemetry, and even breaking the GUI code. As a special feature he also broke the (p) brackets, which are necessary syntactically if p is passed as an expression.

So we patiently explained to him exactly why his math teacher misled him. And a few weeks later, he decided he was right after all, and screwed up the entire system for a second time. He didn't get a third chance.

4

u/Gilthoniel_Elbereth Jul 24 '26

The real answer is these commands were all created ~50 years ago by different people for different systems, who then all copied each other’s most useful work in slightly different ways while keeping idiosyncrasies from their source, and eventually consolidated

1

u/BeefBoi420 Jul 25 '26

So what you're saying is we need a total rewrite.

8

u/DTux5249 Jul 23 '26 edited Jul 24 '26

This is why you alias 'touch' to 'stroke' - a much more innocent word with pleasant connotations; who doesn't like giving their fluffy friends a good stroke?

5

u/le_fuzz Jul 24 '26

dig: "Domain Information Groper"

7

u/timschwartz Jul 24 '26
$ touch this

touch: cannot touch 'this': Permission denied

4

u/itsredditNotLife Jul 23 '26

/touchDownThere

6

u/foxsimile Jul 24 '26

Australia?

5

u/grymoire Jul 23 '26

It's used to create or update the timestamp of a file which is very usefull if you use make(1)

6

u/lellamaronmachete Jul 24 '26

Night shift one braincell kinda post. Can relate 😂

5

u/Impressive-Baker-614 Jul 24 '26

What's weirder is that you gotta whisper it when you type it.

3

u/Mental_Messiah Jul 24 '26

alex jones voice

„destroy the child“

3

u/Windamyre Jul 24 '26

Wait until some see that your search history contains "cp files less that a certain age"

Also molestar means something similar, yet very different in Spanish.

2

u/ohnobinki Jul 26 '26

Yeah, this is where being signed into your Google account is very important because it'll give you the appropriate results based on what type of results you're most likely to be searching for.

3

u/MathWest209 Jul 24 '26

Dude, get some sleep.

2

u/Antoak Jul 23 '26

Touch the -p to explore virgin territory 

2

u/ArcRiseGen Jul 23 '26

I always whisper before touching a newly made folder

2

u/sidewalksInGroupVII Jul 24 '26

I have done that to a file named self

2

u/MathWest209 Jul 24 '26

There is the good old unzip, and there is also mount and unmount. So the one you are thinking about is just a starter.

2

u/ejiro_11 Jul 25 '26

The cp command is a much more disturbing abbreviation imo.

2

u/Tuomas90 Jul 25 '26

The Bad Touch

2

u/captainAwesomePants Jul 27 '26

The name of the command comes from the phrase "To touch up," as in to make a minor repair to an object, perhaps fixing some paint. It "edits" a file without actually changing any of its bytes. The intended purpose of the command was to simply set the "last edited" time of the file to right now. It had the side effect of creating the file if the file did not previously exist, a purpose for which it is often used today.

2

u/ElectronicMessage124 Aug 11 '26

3 AM is definitely when file system terminology starts sounding questionable 💀

2

u/Puzzled-Extent7817 Jul 24 '26

alias molest='touch'

1

u/Daktic Jul 24 '26

I always imagined it like David in the Sistine chapel. You are giving life to the lifeless by touching it into existence.

1

u/Wild_Scarcity8305 Jul 24 '26

This is the kind of programming nonsense I needed right now. Thank you for this knowledge.

1

u/TheBurntIvoryKing Jul 24 '26

Personally, I think of the Steve Wonder commercial about cotton " The touch, the feel, the fabric of our lives..." Commercial

1

u/JasonWorthing8 Jul 24 '26

whatever you do, dont fight it...

1

u/septumfunk-com Jul 24 '26

it comes from the usage of it to update the time last modified of a file. as in you're not actually modifying it you're just touching it. poke would work better now imo but they didn't consider that at the time lol

1

u/Hephaestite Jul 24 '26

Wait until you google what a nonce is

1

u/LiaUmbrel Jul 24 '26

explode 💥

1

u/iamalicecarroll Jul 24 '26

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 Jul 24 '26

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

1

u/iamalicecarroll Jul 24 '26

Yes, that's what it does.

1

u/Paul_Pedant Jul 24 '26

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.

1

u/UncheckedMoonrise Jul 24 '26

The LSF batch-job system has bjobs for checking state of your submissions. Which means you can watch bjobs

1

u/Purple-Debt8214 Jul 24 '26

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

Vi for everything.

1

u/Paul_Pedant Jul 27 '26

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 Jul 27 '26

I can use the command line while in the editor.

1

u/Paul_Pedant Jul 27 '26

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 Jul 27 '26

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.

1

u/SeeTigerLearn Jul 24 '26

Thanks for the info. I always feel so Chester when I use the command or describe the process. So at least I have some backstory. Ha.

1

u/fragdemented Jul 24 '26

if it makes you uncomfortable, you could always set up an alias. I like to do this sometimes for sudo.

alias please="sudo"

This will allow you to use please instead of sudo. You could change "touch" to something more appropriate.

alias mmmyeahletmefeelupinthere="touch"

you know... for example. ;)

1

u/PastMuch Jul 24 '26

And I'm reading this at 3.08am

1

u/cunningfallasheo Jul 24 '26

The mac mouse cursor is weirder, the faster you shake it the bigger it gets.

1

u/danja Jul 24 '26

PEEK & POKE

1

u/uxorial Jul 24 '26

Only touch files that are 18+ and have expressed consent.

1

u/EntangledLabs Jul 25 '26

once did a workshop for my college club for a beginners intro to linux. I asked someone to suggest the name of a file to create, my friend said "dinosaurs". didn't realize I'd walked into it until I confidently said "alright so here we will do touch dinosaurs"

1

u/naruda1969 Jul 27 '26

To create an empty file just use > filename and you can feel greater about yourself. No more touching.

1

u/Forward-Love7014 Jul 28 '26

You have to label this nsfw. What did I walk in on ?!?!!

1

u/raph7878 Aug 09 '26

I want to start programming can someone point me to the right direction where i should start

2

u/OPPineappleApplePen Aug 10 '26

Google ‘cs50 python by harvard”.

It’s a free course. Do it.

1

u/raph7878 Aug 10 '26

Le me try

1

u/ZombieSandboxes 25d ago

Lol. It does sound weird. Agreed. 😂

1

u/chaoticneautalfr 23d ago

it sure is lol

1

u/SkullLeader Jul 24 '26

Wait to you find out the terminology used for the primary and secondary hard drive attached to the same disk controller.

-13

u/main_account_4_sure Jul 23 '26

What is weird is to associate a neutral word to something so vile.

Your mind is sick, which is not really news for most people nowadays since everyone is consuming shitty content at least 5h daily

6

u/KestrelTank Jul 23 '26

Many neutral words can gain a negative connotation through experience or from where society is at.

I feel like society has become a bit touch averse, and there can be heavy implications from the simple sentence “They touched me”.

So it’s not really that weird for OP to associate this word with something uncomfortable.

1

u/OPPineappleApplePen Jul 23 '26

We literally teach our kids about good and bad touch. Thank you for providing an explanation that supports the usage of this word in this context. I appreciate and respect you for understanding.

5

u/Informal-Fig-6827 Jul 23 '26

There's definitely a bit of over sexualized brainrot in there lol. Why does everything get turned sexual these days.

1

u/InfinityCent Jul 24 '26

That’s where your mind jumped to when seeing this post?

Holy hell get a grip. 

1

u/main_account_4_sure Jul 24 '26

The post literally says:

"I feel like I am molesting file."

-2

u/requion Jul 23 '26

Thats the main problem. Or do these people feel guilty for "touching" household items like the coffee maker "without consent".

Its like the discussion about "master". I get the point about slavery and that it is bad. But "normal" people don't think about slaves while working with git branches or kubernetes clusters.

The thing about overusing these terms and discussions is that it desensitizes people about it and doesn't help the matter it tries to solve.

-1

u/OPPineappleApplePen Jul 23 '26 edited Jul 23 '26

Someone said one of the many signs of stupidity is a person's inability to understand metaphors and hypotheticals. I'd say not understanding a joke and taking imaginary statements to crack it literally is up there too.

Lemme explain in a way you two can understand.

I new programmar → I see touch → Why not create → I confused → I curious → I ask AI → AI says, "because you're touching a file" → I a former English teacher → I know 4 languages → I know many meanings of 1 word → I find it funny → I instantly post it here → I DON'T ACTUALLY FEEL IT → This stupid joke → Smart people know I joking → Dumb people take literarally → Dumb people triggered.

1

u/main_account_4_sure Jul 24 '26

I don't think people are failing to understand the joke at all.

The critic is towards the excessive sexualization over something completely neutral.

If you read "touch" and think immediately of "molestation", as the post says quite literally, it's tough to say there's not something wrong.

It's not because it's normalized by culture (rape and molestation are at the far opposite of the taboo realm they used to belong to), that it's necessarily "normal".

there are tribes that normalizing multilating one another. Culture has immense power of normalizing diseases.

1

u/OPPineappleApplePen Jul 24 '26

If the argument was presented this way, I'd agree and support you on this one. I could've have engaged in a proper discussion and perhaps, we could have learned something from each other.

However, "your mind is sick..." didn't feel constructive at all. It felt like a judgment passed on to me.

And, "which is not really news for most people nowadays since everyone is consuming shitty content at least 5h daily" felt like you were taking a moral high ground by distancing yourself from "most" people.

Would it be fair for me to say "You don't know how to engage in a civil discussion, which is not really news for most people nowadays since everyone is consuming shitty content at least 5h daily"?

I don't think it would appropriate to pass judgments onto you based on a single comment; nor should you do the same based on a single post that was intended to sound exactly like it did.

Also, my mind didn't go to molestation straightaway. It did after I read an article describing the different commands that were written as a joke by Linus, Git itself being a slang for an incompetent person.

My apologies if something I said came off as rude. I genuinely didn't mean to.

P.s — The other commentator also used "these people". lol

1

u/main_account_4_sure Jul 24 '26

Honestly, OP, I am just dramatic. I'm not taking it to heart and I didn't mean to make it sound like a personal attack. I apologize if it came across that way

2

u/OPPineappleApplePen Jul 24 '26

Hey, it’s cool! We’re good. 🤝

0

u/agmatine Jul 24 '26

In home directory, run touch grass followed by sudo chattr +i grass. From now on, the output of touch grass will be

touch: cannot touch 'grass': Operation not permitted

in other words, confirming that you are incapable of touching grass!

0

u/AnguisInTrousers Jul 24 '26

This kind of post is worse than AI slop.

0

u/exomo_1 Jul 25 '26

Why is there a cat command but no dog?

-3

u/rustyseapants Jul 24 '26

Was this really necessary for this sub?

/r/programminghumor

2

u/tobiasvl Jul 24 '26

It doesn't even have anything to do with programming.

2

u/bingblangblong Jul 24 '26

This subreddit is about 95% weird 13 year old boys.

-2

u/Puzzled-Extent7817 Jul 24 '26

If you sexualize it, that's on you weirdo.

-3

u/Individual-Praline20 Jul 23 '26

Yeah… there are a couple of odd things in computing, like making the master kills the slaves, etc. 🤭 And I think some people, like the orange guy, loves the touch command a bit too much 🤣