home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Unix Power ToolsUnix Power ToolsSearch this book

12.5. What's in That Whitespace?

The cat -v option (Section 12.4) shows an ASCII representation of unprintable and non-ASCII characters. cat has two options for displaying whitespace 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 may have to be typed separately, by the way; -te won't work on some versions):

% 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 whitespace 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

Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.