linuxmacosterminalzsh

Mac OS Catalina zshell : cat -A is illegal so what's is the substitute?


In a typical linux system we can use cat -A [file] to output the file with tabs shown as ^I and a $ sign at the true end of the line which indicates how many spaces are there at the end of the line.

But in my Mac OS Calatlina zsh terminal, I get the following error

tilak@Tilaks-Macbook-Pro ~ % cat -A file.txt
cat: illegal option -- A
usage: cat [-benstuv] [file ...]
tilak@Tilaks-Macbook-Pro ~ % 

I have tried cat -tv [file] but that has the same output as cat [file]

Here is the cat manual for -tv options...

-t Display non-printing characters (see the -v option), and display tab characters as `^I'.

-v Display non-printing characters so they are visible. Control characters print as `^X' for control-X; the delete character (octal 0177) prints as `^?'. Non-ASCII characters (with the high bit set) are printed as `M-' (for meta) followed by the character for the low 7 bits.

idk if it helps but ... Currently referring book: William Shotts - A Linux Command Line complete introduction _ (No Starch Press 2019)


Solution

  • I use cat -vet
    In this order, it is easy for me to remember -- my Mac cat needs a vet.

    option desc
    -v <Display non-printing characters so they are visible. Control characters print as ‘^X’ for control-X; the delete character (octal 0177) prints as ‘^?’. Non-ASCII characters (with the high bit set) are printed as ‘M-’ (for meta) followed by the character for the low 7 bits.
    -e Display non-printing characters (see the -v option), and display a dollar sign (‘$’) at the end of each line.
    -t Display non-printing characters (see the -v option), and display tab characters as ‘^I’.