I'd like to be able to print and see the trailing whitespaces in the text file (just display, not remove).
I've tried with cat -v which suppose to display non-printing characters, but it doesn't display them as expected (no visual difference between the lines). E.g.
$ printf "foo\nbar \t\n" > file.txt
$ cat -v file.txt
foo
bar
By print/display whitespaces I mean some visual human indication that the trailing whitespace is there in comparison to other lines without, either by some special character, color (like when files are displayed using git diff) or something similar.
Is there any other way?
Note: I'm on macOS Sierra, however I've got access to both GNU and BSD cat commands:
$ type -a cat
cat is /usr/local/opt/coreutils/libexec/gnubin/cat
cat is /bin/cat
$ cat --version
cat (GNU coreutils) 8.28
$ /bin/cat --version
/bin/cat: illegal option -- -
usage: cat [-benstuv] [file ...]
-v.-Edoesn't exist for/bin/cat, but I've got GNUcatinstalled as well.cat -vdoes work, it just doesn’t do what you think it does — trycat -v /dev/urandom | headto see how it affects output.-Edoes exist for/bin/cat, which version are you talking aboutcat -vprints non-printing characters fine, however whitespace is still a whitespace, so it's not really human visible in the terminal./bin/cat -E file.txt->/bin/cat: illegal option -- E.