abuseofcats.com — a public service announcement about cat(1)
$ cat /etc/app/config | grep -v '^#'
abuse. this cat did nothing wrong.
/\_/\
( ;_; )
> ^ <
$ grep -v '^#' /etc/app/config
humane. same output, one less process.
/\_/\
( ^.^ )
> ^ <
grep can open files by itself. 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.
cat(1) is for concatenating files. Let cat be cat.
other cats in danger:
| 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 |