ch12 07


Squash Extra Blank Lines (Unix Power Tools, 3rd Edition) 12.7. Squash Extra Blank Lines Reading output with lots of empty lines can be a waste of screen space. For instance, some versions of man (Section 2.1) show all the blank lines between manual pages. To stop that, read your file or pipe it through cat -s. ( Many versions of less (Section 12.3) and more have a similar -s option.) The -s option replaces multiple blank lines with a single blank line. (If your cat doesn't have -s, see the sed alternative at the end.) cat -s might not always seem to work. The problem is usually that the "empty" lines have SPACE, TAB, or CTRL-m characters on them. The fix is to let sed "erase" lines with those invisible characters on them: % sed 's/^[SPACE TAB CTRL-v CTRL-m]*$//' file | cat -s In vi (Section 18.6) and many terminal drivers, the CTRL-v character quotes the CTRL-m (RETURN) so that character doesn't end the current line. If you don't have cat -s, then sed can do both jobs: % sed -e 's/^[SPACE TAB CTRL-v CTRL-m]*$//' -e '/./,/^$/!d' file -- JP 12.6. Finding File Types12.8. How to Look at the End of a File: tail Copyright © 2003 O'Reilly & Associates. All rights reserved.

Wyszukiwarka

Podobne podstrony:
ch12
ch12 (15)
ch12 (16)
ch12
ch12
ch12
ch12
ch12
ch12
ch12
ch12
ch12
ch12
ch12
budynas SM ch12
ch12
CH12
ch12 (3)

więcej podobnych podstron