DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Manipulating text with sed

Miscellaneous functions

There are three other functions of sed not discussed in the sections above.


=
The = function writes the number of the line matched by its address to the standard output. One address is possible.

The length of a file can be found using the following command:

$ =

This command is not counting the lines, but rather showing the length of the file by printing the number of the last line.


l
The list function is used to display the contents of the pattern space. Non-printable characters such as BEL (\a) are displayed as two digit ASCII codes.

q
The q function causes the current line to be written to the output (if it should be), any appended or read text to be written, and execution to be terminated. One address is possible. This function could be used to shorten processing if, for example, the objective was to truncate a very long file at the first occurrence of a given word, by copying the input to the output then quitting as soon as the word was encountered.

Previous topic: Comments in sed

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003