关于滥用 cat(1) 命令的公告。请勿滥用 cat。
PSA about abuse of cat(1) command. Don't abuse cats

原始链接: https://www.abuseofcats.com

abuseofcats.com — 关于 cat(1) 的公益广告 ``` $ cat /etc/app/config | grep -v '^#' 滥用。这只 cat 没做错什么。 /\_/\ ( ;_; ) > ^ < $ grep -v '^#' /etc/app/config 人道。同样的输出,少了一个进程。 /\_/\ ( ^.^ ) > ^ < grep 可以自行打开文件。通过管道将单个文件传给 cat 只会衍生出一个毫无必要的进程,它的唯一工作就是将字节复制给 一个本就知道如何读取这些字节的程序。 cat(1) 是用来连接(concatenate)文件的。让 cat 做它该做的事。 其他处于危险中的猫: 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 由 Scooter(又名 Jeremie King)制作 · feedback@jeremieking.com ```

抱歉。
相关文章

原文

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 -lwc -l < file
cat file | head -n 5head -n 5 file
cat file | awk '{print $1}'awk '{print $1}' file
cat file | sortsort file
联系我们 contact @ memedata.com