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

scooterbooper1 pts0 comments

abuseofcats.com — stop abusing cat(1)

abuseofcats.com — a public service announcement about cat(1)

$ cat /etc/app/config | grep -v '^#'<br>abuse. this cat did nothing wrong.

/\_/\<br>( ;_; )<br>> ^

$ grep -v '^#' /etc/app/config<br>humane. same output, one less process.

/\_/\<br>( ^.^ )<br>> ^

grep can open files by itself. Piping a single file through<br>cat spawns an entire process whose only job is to copy bytes to a<br>program that already knew how to read them.

cat(1) is for concat enating files. Let cat be cat.

other cats in danger:

cat file | wc -lwc -l<br>cat file | head -n 5head -n 5 file<br>cat file | awk '{print $1}'awk '{print $1}' file<br>cat file | sortsort file

file abuse grep cats abuseofcats config

Related Articles