Small shell tools for text editing
|
Statistics with wc
The wc command is interesting if you need to pay particular attention to characters, words, or lines. For example, you can use wc to provide parameters to prepare for printing. The wc command can be applied directly to files or can be piped. Table 10 shows the main options.
The GNU version of wc described here provides, among other things, the option to extract the number of characters in the longest line of the document. You can use this information to create an attractive print output for encscript or latex , because this is an important factor in the choice of font size or page orientation. Running the program without options gives you the line, word, or byte count. Figure 6 provides some examples.
Numbering Lines
You can impose line numbering for (print) output independently of an editing (or other) application. The nl program works with text files and pipes. Table 11 lists the options.
For example, you would do the following:
cat e.txt | nl -v 10 -i10 -ba -w 3-nrz
to number all lines in the piped data with a starting value of 10 and an increment of 10, making the numbers three characters (000 ) wide.
Buy this article as PDF
Pages: 1
(incl. VAT)