Yeah. It could just as well have issued a file not found error when you try to touch a nonexistent file. And we would be none the wiser about what we’re missing in the world.
This is an interesting idea to allow non-root users to restart a service. It looks like this is doable with systemd too. https://superuser.com/a/1531261
It is short for concatenate, which is to join things together. You can give it multiple inputs and it will output each one directly following the previous. It so happens to also work with just one input.
I sometimes use cat to concatenate files. For example, add a header to a csv file without manually copy and paste it. It’s rare, but at least more frequent than using touch.
When you updated a Django server, you were supposed to touch the settings.py file so the server would know to reload your code. (I haven’t used any for a long time, so I don’t know if it’s still the procedure.)
I used it recently to update the creation date of a bunch of notes. Just wanted them to display in the correct order in Obsidian. Besides that though, always just used it for file creation lol
Ahhhhh, fuck. I’m quite noob with linux. I got into some rabbit hole trying to read the docs. I found 2 man pages, one is cat(1) and the other cat(1p). Apparently the 1p is for POSIX.
If someone could help me understand… As far as I could understand I would normally be concerned with (1), but what would I need to be doing to be affected by (1p)?
If you execute a binary without specifying the path to it, it will be searched from the $PATH environment variable, which is a list of places to look for the binary. From left to right, the first found one is returned.
You can use whichcat to see what it resolves to and whereis cat to get all possible results.
If you intentionally wants to use a different binary with the same name, you can either directly use its path, or prepend its path to $PATH.
I mean, timestamps aren’t really all that useful. Really just if you do some stuff with makefiles but even then it’s a stretch. I did once use cat for its intended purpose tho, for a report. We split up the individual chapters into their own files so we have an easier time with git stuff, made a script that had an array with the files in the order we wanted, gave it to cat and piped that into pandoc
Yes, when you are for example checking if the permissions in the directory are correct, or if you want to check if your nfs export is working. It’s one of those commands that once you know it exists, you WILL find a way to use it.
Creating an empty file is one of its intended purposes. Unix commands were designed as multi-purpose primitives, so they could be reused and composed to handle many different tasks. The touch command is no exception.
Does anyone actually use
touch
for its intended purpose? Must be up there withcat
.TIL it’s actually for changing timestamps.
https://www.man7.org/linux/man-pages/man1/touch.1.html
Wtf. All these years I thought ‘touch’ was reference to Michelangelo’s Creation of Adam.
That’s beautiful, bro 🥲
touché
That’s not how you use “touché”. Pet peeve of mine.
Touché!
🇪🇳 🇬🇦🇷🇩🇪
or…
ʳᶦᵖᵒˢᵗᵉ…?
The intended use of
touch
is to update the timestamp right?Yeah. It could just as well have issued a file not found error when you try to touch a nonexistent file. And we would be none the wiser about what we’re missing in the world.
If you
touch -c
it should work I guessWe use it to trigger service restarts.
touch tmp/service-restart.txt
Using
monit
to detect the timestamp change and do the actual restart command.This is an interesting idea to allow non-root users to restart a service. It looks like this is doable with systemd too. https://superuser.com/a/1531261
Indeed. Replacing monit with systemd for this job is still on our todo list.
what is cat’s use if not seeing whats inside a file?
It is short for concatenate, which is to join things together. You can give it multiple inputs and it will output each one directly following the previous. It so happens to also work with just one input.
That’s why we have
bat
nowhttps://github.com/sharkdp/bat
To bonbatenate files?
Exactly
Bat bat bo-at
Bonbaten-fana fo-fat
Fee-fi-fo-fat
Bat!
Cat with wings? Isn’t a bat more like a rat with wings?
TIL
I never realized. Thanks!
It is to use along with
split
. e.g.split
to break it into multiple files of 4GBcat
to combine all files into the original file. (preferably accompanied by a checksum)I sometimes use cat to concatenate files. For example, add a header to a csv file without manually copy and paste it. It’s rare, but at least more frequent than using touch.
$ cat file1 > output_file $ cat file2 >> output_file $ cat file3 >> output_file
I’m sorry!
That’s its intended purpose - combining files together (the opposite of
split
). See the first line of the man page: https://man7.org/linux/man-pages/man1/cat.1.htmlWhen you updated a Django server, you were supposed to touch the settings.py file so the server would know to reload your code. (I haven’t used any for a long time, so I don’t know if it’s still the procedure.)
There are many small things that use it.
it now has a hot reload, How long ago were you using Django?
I used it recently to update the creation date of a bunch of notes. Just wanted them to display in the correct order in Obsidian. Besides that though, always just used it for file creation lol
Ahhhhh, fuck. I’m quite noob with linux. I got into some rabbit hole trying to read the docs. I found 2 man pages, one is cat(1) and the other cat(1p). Apparently the 1p is for POSIX.
If someone could help me understand… As far as I could understand I would normally be concerned with (1), but what would I need to be doing to be affected by (1p)?
If you execute a binary without specifying the path to it, it will be searched from the $PATH environment variable, which is a list of places to look for the binary. From left to right, the first found one is returned.
You can use
which cat
to see what it resolves to andwhereis cat
to get all possible results.If you intentionally wants to use a different binary with the same name, you can either directly use its path, or prepend its path to $PATH.
I don’t know anything about Linux but I do love touching cats
You would love Linux cli.
Cat is actually super useful.
I mean, timestamps aren’t really all that useful. Really just if you do some stuff with makefiles but even then it’s a stretch. I did once use cat for its intended purpose tho, for a report. We split up the individual chapters into their own files so we have an easier time with git stuff, made a script that had an array with the files in the order we wanted, gave it to cat and piped that into pandoc
Yes, Nextcloud can’t sync files with a timestamp of 0
Yup, stupid zip files and their directories from 1970
Yes, when you are for example checking if the permissions in the directory are correct, or if you want to check if your nfs export is working. It’s one of those commands that once you know it exists, you WILL find a way to use it.
Well, those aren’t really the intended use either.
I use it regularly
Creating an empty file is one of its intended purposes. Unix commands were designed as multi-purpose primitives, so they could be reused and composed to handle many different tasks. The touch command is no exception.
https://www.youtube.com/watch?v=tc4ROCJYbm0&t=287s
I use it all the time, especially in ssh on a server.
i use both frequently but im also a pretty dumb user