Post History
cat -v It's not a problem if cat produces a mess of strange symbols, but it could be a problem (or even a security risk) if the output contains, in particular, ANSI control codes. cat general...
#1: Initial revision
## `cat -v`
> It's not a problem if `cat` produces a mess of strange symbols, but it could be a problem (or even a security risk) if the output contains, in particular, ANSI control codes.
`cat` generally already offers a flag to deal with this:
```
-v, --show-nonprinting
use ^ and M- notation, except for LFD and TAB
```
The choice of `-v` is perhaps cryptic (and the explanation in my distro's man page doesn't really explain the purpose; it also isn't clear that "LFD" means "line feed" as this would usually be called "LF"), but it's specifically designed for the purpose:
```
$ echo -e '\e[1;31;103mHello\b\b\b\b\bこんにちは\e[0m' | cat -v
^[[1;31;103mHello^H^H^H^H^HM-cM-^AM-^SM-cM-^BM-^SM-cM-^AM-+M-cM-^AM-!M-cM-^AM-/^[[0m
```
Unlike `vis`, it doesn't use backslash sequences, and thus doesn't round-trip. (It's also historically a [famous example](https://harmful.cat-v.org/cat-v/) used for complaints about UNIX failing to follow the UNIX philosophy.)
