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
$ 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 ...]