UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 25.5 Page Through Compressed, RCS, Unprintable Files Chapter 25
Showing What's in a File
Next: 25.7 Show Non-Printing Characters with cat -v or od -c
 

25.6 What's in That White Space?

The cat -v option (25.7) shows non-printable characters in a printable way. cat has two options for displaying white space in a line. If you use the -t option with -v, TAB characters are shown as ^I. The -e option combined with -v marks the end of each line with a $ character. Some versions of cat don't require the -v with those options. Let's compare a one-line file without and with the -t -e (which have to be typed separately, by the way; -te won't work):

% cat afile
This is a one-line file - boring, eh?
% cat -v -t -e afile
ThiS^Hs is^Ia one-line file^I- boring, eh?       $

Although you can't tell it from plain cat, there's a backspace (CTRL-h) before the first s, two TABs that take up only one column of white space each, and seven spaces at the end of the line. Knowing this can help you debug problems in printing and displaying files. It's also a help for shell programmers who need to parse or sort the output of other programs.

- JP


Previous: 25.5 Page Through Compressed, RCS, Unprintable Files UNIX Power ToolsNext: 25.7 Show Non-Printing Characters with cat -v or od -c
25.5 Page Through Compressed, RCS, Unprintable Files Book Index25.7 Show Non-Printing Characters with cat -v or od -c

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System