# PSA: Stop Abusing the cat Command and Let Cats Be Cats

Original title: PSA about abuse of cat(1) command. Don't abuse cats

> Hacker News story 48953719 · language: en · submitted 2026-07-18
> Web version: https://zeli.app/story/48953719
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 31 · by [scooterbooper](<https://news.ycombinator.com/user?id=scooterbooper>) · 💬 57
[original](<https://www.abuseofcats.com>) · [HN discussion](<https://news.ycombinator.com/item?id=48953719>)

## Summary

I'm sharing a public service announcement to stop the unnecessary abuse of the cat command in shell scripts. Piping a single file through cat spawns an extra process that does nothing but copy bytes to a program that can already read the file itself. Tools like grep, wc, head, and awk can open files directly. Let's be humane and let cat do what it was designed for: concatenating multiple files.

## Key quote

> Piping a single file through cat spawns an entire process whose only job is to copy bytes to a program that already knew how to read them.

## HN discussion (57 comments)

### [internet2000](<https://news.ycombinator.com/item?id=48954513>)

> \> Piping a single file through cat spawns an entire process whose only job is to copy bytes to a program that already knew how to read them.
>
> Chrome probably spawned two processes when I cmd+clicked this into a new tab. It really doesn't matter.

### [jasongi](<https://news.ycombinator.com/item?id=48954828>)

> The beauty of cat is that streams are the universal interface.
>
> Program A might accept a file as the last positional arg. Program B might accept it as a named arg, where the name/flag could be anything from --input or -f or --file etc.
>
> But a program will read from STDIN, which all good unix programs do, then piping cat into it works every time. I can write the cat foo.txt part before I even know what command I'm piping it into.

### [lifthrasiir](<https://news.ycombinator.com/item?id=48954555>)

> Don't do this:
>
> cat file | wc -l            => wc -l < file
>
> cat file | head -n 5        => head -n 5 file
>
> cat file | awk '{print $1}' => awk '{print $1}' file
>
> cat file | sort             => sort file
>
> Do this instead:
>
> cat file | wc -l            => <file wc -l
>
> cat file | head -n 5        => <file head -n 5
>
> cat file | awk '{print $1}' => <file awk '{print $1}'
>
> cat file | sort             => <file sort
>
> The front-cat abuse is all about the order. The effective solution needs to keep the relative order of arguments.

### [MPSimmons](<https://news.ycombinator.com/item?id=48954773>)

> Unless you're executing these commands in a loop over a large number of items, or the item itself is gargantuan, it's almost always harmless.
>
> Personally, when I'm exploring, I build a command line iteratively. Cat the file to see the content, pipe to grep to get the lines I want, sed/awk/cut/etc to finagle from there.

### [jmclnx](<https://news.ycombinator.com/item?id=48954380>)

> In this day an age this is still making rounds ?  So this is the memory usage of cat on my system:
>
> VSZ   RSS    SZ CMD
>
> 3252  1608   813 /bin/cat
>
> To me there are far more things to worry about than cat.  How about your multi-gig browser for one ?
>
> Now for firefox:
>
> VSZ    RSS     SZ CMD
>
> 3472212 395968 868053 /usr/lib64/firefox/firefox
>
> Maybe people should be looking at that ?  I will not even get into modern Linux Desktops :)

---

## Cite

- Page: https://zeli.app/story/48953719
- Date: 2026-07-18
- Source: abuseofcats.com (https://www.abuseofcats.com)
- Hacker News: https://news.ycombinator.com/item?id=48953719

## Other languages

- zh: https://zeli.app/zh/story/48953719 · markdown: https://zeli.app/zh/story/48953719.md
- ja: https://zeli.app/ja/story/48953719 · markdown: https://zeli.app/ja/story/48953719.md
- ko: https://zeli.app/ko/story/48953719 · markdown: https://zeli.app/ko/story/48953719.md
- de: https://zeli.app/de/story/48953719 · markdown: https://zeli.app/de/story/48953719.md
- es: https://zeli.app/es/story/48953719 · markdown: https://zeli.app/es/story/48953719.md
