this post was submitted on 03 Aug 2026
372 points (97.9% liked)

Programmer Humor

32608 readers
964 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

founded 3 years ago
MODERATORS
 

ahh

~$ which cat
top 50 comments
sorted by: hot top controversial new old
[–] HamsterRage@lemmy.ca 4 points 8 hours ago (1 children)

For the past 30 years or so, my brain always tells me to type "last" instead of "tail". This usually results in some kind of "Permission denied" message that confuses me for a few seconds.

[–] shark_byte@lemmy.zip 1 points 7 hours ago (1 children)

there's a last command? just knowing that.

[–] HamsterRage@lemmy.ca 2 points 4 hours ago (1 children)

Yes, but it shows information about recent/current logins and requires access a file called wtmp (or something like that, off the top of my head), and that requires privileged access.

My usual use case where I mix it up is looking at a log file and and I just want to see the last few entries. So my brain 🧠 tells my fingers to type "last logfile", and when I get the permission message it tells my mouth to go, "Doh!".

[–] shark_byte@lemmy.zip 1 points 3 hours ago

yeah I looked it up

this will be handy

~$ last reboot
~$ last -s -7days
[–] Dyskolos@lemmy.zip 5 points 9 hours ago

I was today's years old to finally notice the cat-head-tail thing...

But it also just recently dawned upon me why pacman has those weird "c" as progress indicators...

I'm not a smart man...

[–] Jankatarch@lemmy.world 5 points 19 hours ago (1 children)

Bat is my favorite command to date.

[–] shark_byte@lemmy.zip 3 points 17 hours ago
~$ which bat
~$ bat man
[–] rumba@lemmy.zip 10 points 1 day ago (1 children)
[–] Sprocketfree@sh.itjust.works 3 points 23 hours ago (1 children)

I've always wondered what a good use case for tac would be...

[–] rumba@lemmy.zip 3 points 22 hours ago (1 children)

Reverse chronological order, mostly

tac log.txt |head # would give you newest first

no good for sort because sort already supports -r

no need it for tail on large files because tail already skips to the end.

I do a lot of impromptu bash to sus crap out of logs.

when you're balls deep in

cat log|grep -v foo| rev|cut -f 1-3 -d \ | |rev

Sometimes tac comes in clutch.

[–] Sprocketfree@sh.itjust.works 4 points 19 hours ago

That's fair. I'd usually just use less and drop to the end. My use cases would always need the older log before a newer log though because that's the start of the problem. At least that's how I operate.

[–] dan@upvote.au 76 points 1 day ago* (last edited 1 day ago) (6 children)

cat is misunderstood a lot. The purpose of cat is to combine multiple files together (it's literally short for "concatenate"), like cat *.log to 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:

cat foo.txt | some-command
some-command < foo.txt

For head, tail, grep and some other commands, you can just pass in the file name directly as an argument (e.g. grep whatever foo.txt).

[–] pedz@lemmy.ca 67 points 1 day ago (1 children)
[–] shark_byte@lemmy.zip 17 points 1 day ago (2 children)

awww what's a cat without a head and a tail?

[–] ranzispa@mander.xyz 10 points 1 day ago

I guess depending on your interpretation of without it could either be "cat" or "a".

[–] ranzispa@mander.xyz 10 points 1 day ago (1 children)

Fair, but in general I find it way more useful to use cat for piping.

In most cases I'll do something like

cat file | program
cat file | program | grep
cat file | program | grep | cut

This gets more complicated if the file is at the end of the command.

[–] dan@upvote.au 8 points 1 day ago (1 children)

It wouldn't be at the end, since you'd still be piping into program

program <file | grep | cut
[–] jxk@sh.itjust.works 12 points 1 day ago (2 children)

And <file program | grep | cut works too

[–] ranzispa@mander.xyz 3 points 1 day ago

Oh, thanks! Didn't know that

load more comments (1 replies)
[–] qqq@lemmy.world 11 points 1 day ago (1 children)

You'll see cat FILE | all the time because it's just a natural start to a pipeline. You cat FILE to see the content unfiltered before filtering it with further commands.

it’s just a natural start to a pipeline

[–] eager_eagle@lemmy.world 9 points 1 day ago (1 children)

I still like doing cat file.txt | grep thing because I often re-run it to find something else like cat file.txt | grep thing2 - and if I do that with grep, the pattern sits awkwardly in the middle instead of at the end

[–] tgt@programming.dev 9 points 1 day ago (1 children)

< file.txt grep thing also works.

[–] sqw@lemmy.sdf.org 1 points 15 hours ago

is it more obtuse

[–] lokalhorst@feddit.org 15 points 1 day ago* (last edited 1 day ago) (3 children)

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.txt

[–] dan@upvote.au 11 points 1 day ago* (last edited 21 hours ago) (1 children)

Admittedly I still use cat for this.

This also works too, but it's more verbose:

echo "$(<foo.txt)"

It's mentioned in the Bash man pages:

The command substitution $(cat file) can be replaced by the equivalent but faster $(< file).

EDIT: I was just informed that simply <foo.txt works too.

[–] not_IO@lemmy.blahaj.zone 4 points 22 hours ago (1 children)

how in the world is this not a useless use of echo and equivalent to <foo.txt

[–] dan@upvote.au 4 points 21 hours ago

OK, TIL you can just do <foo.txt. I didn't think that worked. Thanks!

[–] mote@lemmy.ca 18 points 1 day ago

So close! you have to do cat < foo.txt :-) (/s)

You can use less. There are also specialized ones for that purpose like bat.

[–] shark_byte@lemmy.zip 15 points 1 day ago (1 children)

yeah sure but the command is literally written for the humor.

[–] dan@upvote.au 18 points 1 day ago (3 children)

I know, but I just wanted to mention this since a lot of new Linux users end up using cat this way :)

[–] Grail@multiverse.soulism.net 4 points 1 day ago (1 children)
load more comments (2 replies)
[–] A_norny_mousse@piefed.zip 27 points 1 day ago (1 children)

Another all-time favorite:

$ man woman  
No manual entry for woman  
$ touch woman
touch: cannot touch 'woman': Permission denied
[–] TwilightKiddy@scribe.disroot.org 7 points 1 day ago (1 children)

I always thought it's

head | cat | tail

It, of course, waits for an input, which brings up the one and only question...

Have you fed your cat?

[–] shark_byte@lemmy.zip 3 points 1 day ago

of course look meow meow so loud

[–] exu@feditown.com 14 points 1 day ago (2 children)

I've been using a slightly customized bash-cat for years now. Still makes me smile when I see it

[–] shark_byte@lemmy.zip 5 points 1 day ago

yeah I just checked it out it's cute

load more comments (1 replies)
[–] red_tomato@lemmy.world 19 points 1 day ago (1 children)

tac is a cat but faced the other way

[–] shark_byte@lemmy.zip 10 points 1 day ago

ohhh let me check it out lol

[–] Avicenna@programming.dev 5 points 1 day ago* (last edited 1 day ago) (1 children)
[–] LedgeDrop@lemmy.zip 9 points 1 day ago (1 children)
[–] Avicenna@programming.dev 3 points 1 day ago

whatis cat?

[–] reader@lemmy.zip 4 points 1 day ago (2 children)
load more comments (2 replies)
load more comments
view more: next ›