this post was submitted on 03 Aug 2026
354 points (97.8% liked)
Programmer Humor
32608 readers
907 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
catis misunderstood a lot. The purpose of cat is to combine multiple files together (it's literally short for "concatenate"), likecat *.logto combine all log files together.If you're just using it for a single file, then you should just redirect the file to stdin. These two command lines behave similarly:
For
head,tail,grepand some other commands, you can just pass in the file name directly as an argument (e.g.grep whatever foo.txt).Also known as cat abuse.
awww what's a cat without a head and a tail?
I guess depending on your interpretation of without it could either be "cat" or "a".
A kernel?
uhmm no
Fair, but in general I find it way more useful to use cat for piping.
In most cases I'll do something like
This gets more complicated if the file is at the end of the command.
It wouldn't be at the end, since you'd still be piping into
programAnd
<file program | grep | cutworks tooThanks - I didn't know this either!
Oh, thanks! Didn't know that
You'll see
cat FILE |all the time because it's just a natural start to a pipeline. Youcat FILEto see the content unfiltered before filtering it with further commands.I still like doing
cat file.txt | grep thingbecause I often re-run it to find something else likecat file.txt | grep thing2- and if I do that with grep, the pattern sits awkwardly in the middle instead of at the end< file.txt grep thingalso works.is it more obtuse
If I just want to look at the file, is there a better way than
cat foo.txt? I guess I can't just do< foo.txtAdmittedly I still use
catfor this.This also works too, but it's more verbose:
It's mentioned in the Bash man pages:
EDIT: I was just informed that simply
<foo.txtworks too.how in the world is this not a useless use of echo and equivalent to
<foo.txtOK, TIL you can just do
<foo.txt. I didn't think that worked. Thanks!You can use
less. There are also specialized ones for that purpose like bat.So close! you have to do
cat < foo.txt:-) (/s)yeah sure but the command is literally written for the humor.
I know, but I just wanted to mention this since a lot of new Linux users end up using cat this way :)
Is there any downside?
ohhh but it's all humor that's the point of the post.
I mean as a new Linux user, I won't take anything from a humor group seriously.
I would.
I'd be careful of jokes, sure, but geeks often can't help have real discussions. Like in this very thread