The history of why cat -v is considered harmful

if you've been around the block in the *nix community, you've probably heard of cat -v, or seen the site cat -v. but where does the expression come from?

it comes from a paper entitled Program design in the UNIX environment written by Rob Pike, and Brian Kernighan.

in the paper Pike and Kernighan basically discuss UNIX philosophy, and how Berkeley was shitting all over the philosophy and concept. they specifically mention the -n, -s, -b, and -v flags that were added.

now, to understand why this is a big deal, you have to understand at least the core of unix philosophy; do one thing, and do it right.

they argue that adding the -n flag for adding line numbers to the output {s,c}ould be handled by awk, or sed, or even that it should be added as it's own command named linenumber. (on most systems nl is used now)

they also mention the -v flag, which purpose is to "print non-printable characters", meaning if it encounters a \033 character for example, it would print ^[, or nullbyte would be represented as ^@.

they concede that it's a needed tool on the system, but reinstate that cat is not the program that should handle it.

cat is a program meant to concatenate files, and as such should not do any modifications to the input.

give the paper a read, it's worth it. and remember; just cause you can open a can of beans with a hammer, doesn't mean you should.


do one thing, and do it well.