424
Linux Cat (lemmy.zip)

ahh

~$ which cat
top 50 comments
sorted by: hot top controversial new old
[-] dan@upvote.au 85 points 4 days ago* (last edited 4 days ago)

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 74 points 4 days ago
[-] shark_byte@lemmy.zip 18 points 4 days ago

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

[-] qqq@lemmy.world 15 points 3 days ago

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

[-] lokalhorst@feddit.org 16 points 4 days ago* (last edited 4 days ago)

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

[-] mote@lemmy.ca 20 points 4 days ago

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

[-] MonkeMischief@lemmy.today 1 points 2 days ago

If it's really long, I use less , because it breaks it up into navigable pages instead of filling your entire buffer. :)

Never knew about just using < though! Cool!

[-] dan@upvote.au 13 points 3 days ago* (last edited 3 days ago)

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 5 points 3 days ago

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

[-] dan@upvote.au 5 points 3 days ago

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

[-] not_IO 1 points 18 hours ago

i don't think you can but idk why that's by I'm asking

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

[-] shark_byte@lemmy.zip 16 points 4 days ago

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

[-] dan@upvote.au 19 points 4 days ago

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 5 points 3 days ago
[-] shark_byte@lemmy.zip 5 points 4 days ago

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.

load more comments (1 replies)
[-] eager_eagle@lemmy.world 10 points 3 days ago

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 3 days ago

< file.txt grep thing also works.

load more comments (1 replies)
[-] HamsterRage@lemmy.ca 7 points 3 days ago

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.

load more comments (3 replies)
[-] A_norny_mousse@piefed.zip 28 points 4 days ago

Another all-time favorite:

$ man woman  
No manual entry for woman  
[-] TwilightKiddy@scribe.disroot.org 20 points 3 days ago
$ touch woman
touch: cannot touch 'woman': Permission denied
[-] rumba@lemmy.zip 11 points 3 days ago
[-] Sprocketfree@sh.itjust.works 3 points 3 days ago

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

[-] rumba@lemmy.zip 3 points 3 days ago

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 3 days 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.

[-] red_tomato@lemmy.world 21 points 4 days ago

tac is a cat but faced the other way

[-] shark_byte@lemmy.zip 12 points 4 days ago

ohhh let me check it out lol

[-] exu@feditown.com 14 points 4 days ago

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

[-] shark_byte@lemmy.zip 6 points 3 days ago

yeah I just checked it out it's cute

load more comments (1 replies)
[-] Jankatarch@lemmy.world 6 points 3 days ago

Bat is my favorite command to date.

[-] shark_byte@lemmy.zip 5 points 3 days ago
~$ which bat
~$ bat man

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 4 points 3 days ago

of course look meow meow so loud

[-] anotherspinelessdem@lemmy.ml 10 points 4 days ago
[-] darth_grunkus@lemmy.world 12 points 3 days ago* (last edited 3 days ago)
[-] Avicenna@programming.dev 6 points 3 days ago* (last edited 3 days ago)
[-] reader@lemmy.zip 4 points 3 days ago
[-] selarian@lemmy.world 5 points 3 days ago

Be careful now, 2000/2010 Linux terminology can be taken as an insult in 2026. /s

I’m tired of this stupid coddling bullshit with the influx of new Linux users. If you can’t read don’t use Linux. Simple. 😂

load more comments (2 replies)
load more comments
view more: next ›
this post was submitted on 03 Aug 2026
424 points (100.0% liked)

Programmer Humor

32666 readers
815 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