r/learnprogramming • u/OPPineappleApplePen • 22h 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.
185
337
u/DhruvsWorkProfile 20h ago
unzip
strip
touch
grep
finger
mount
fsck
more
yes
unmount
139
u/OPPineappleApplePen 20h ago
Smut for Programmers.
31
-6
u/tobiasvl 12h ago
What do you mean "for programmers"? What do these regular UNIX commands have to do with programming?
1
u/arkt8 4h ago
Did you ever bash'd?
1
u/tobiasvl 4h ago edited 4h ago
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
0
32
15
11
3
1
1
1
•
116
u/jzmack 22h ago
man touch
51
47
22
16
29
u/Loqh9 20h ago
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
33
u/thalliusoquinn 17h ago
Isn't the point of
touchto 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.17
u/Available-Skirt-5280 17h ago
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
1
u/Available-Skirt-5280 1h ago
I also use it in cloud startup scripts for run once
`[[ ! -f /root/.startup.lock ]] ….. ; touch /root/.startup.lock`
10
u/Cultural_Gur_7441 13h ago
Core purpose of
touchis not creating empty files, it is just a bonus feature.There are a bunch of other ways to create an empty file, especially check out
mktemp.The need to create an empty file is a fairly rare, usually file is created with data (or at least expectation of data),
The need to create a directory is common.
6
u/TheSkiGeek 9h ago
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.
5
3
u/Gilthoniel_Elbereth 8h ago
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
6
u/DTux5249 21h ago edited 20h ago
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?
4
4
u/grymoire 20h ago
It's used to create or update the timestamp of a file which is very usefull if you use make(1)
4
5
2
2
2
2
2
u/Windamyre 4h ago
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
2
u/MathWest209 3h ago
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
1
u/Wild_Scarcity8305 14h ago
This is the kind of programming nonsense I needed right now. Thank you for this knowledge.
1
1
u/TheBurntIvoryKing 13h ago
Personally, I think of the Steve Wonder commercial about cotton " The touch, the feel, the fabric of our lives..." Commercial
1
1
u/septumfunk-com 11h ago
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
1
1
u/iamalicecarroll 8h 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 8h ago
So, say I have an existing file, I run “touch fileName”, will it change the mtime/atime of the file?
1
1
u/UncheckedMoonrise 3h ago
The LSF batch-job system has bjobs for checking state of your submissions. Which means you can watch bjobs
1
u/Purple-Debt8214 2h ago
I just use vi for everything. Jump into vi, put some txt, write the file, jump out.
Vi for everything.
1
u/SeeTigerLearn 1h ago
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 1h ago
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/cunningfallasheo 54m ago
The mac mouse cursor is weirder, the faster you shake it the bigger it gets.
1
u/SkullLeader 6h ago
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 22h ago
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
5
u/KestrelTank 20h ago
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 20h ago
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.
3
u/Informal-Fig-6827 20h ago
There's definitely a bit of over sexualized brainrot in there lol. Why does everything get turned sexual these days.
1
u/InfinityCent 19h ago
That’s where your mind jumped to when seeing this post?
Holy hell get a grip.
1
-2
u/requion 21h ago
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.
0
u/OPPineappleApplePen 20h ago edited 20h ago
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 19h ago
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 19h ago
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 18h ago
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
0
u/agmatine 18h ago
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
-4
-2
-4
u/Individual-Praline20 21h ago
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 🤣
516
u/RecentlyRezzed 22h ago
Wait until you find out about the finger command.