User's manual. Section 1.

LNS(1): print lines


USAGE

        usage: lns [-Dnpu] {-r range} {file}
            -D: debug
            -n: print line numbers
            -p: print file names and line numbers
            -r range: print this range
            -u: use unix out
        

DESCRIPTION

Lns prints selected lines for files in the input. Lines are specified as ranges. A range may be a single line number, counting from 1, or a pair of start and end line numbers separated by a "," character. Negative line numbers count backwards from the end of the file (the last is -1 and so on).

Multiple ranges may be given. But beware, in such case, to avoid storing the entire file, ranges involving only positive line numbers are printed first and then ranges involving negative line numbers. Depending on the ranges given, this might lead to unsorted line prints.

A missing start number in a range means 1, and a missing end number in a range means -1. If no range is given, "," is implied. And, when such range is indicated, all lines are printed, one line at a time. This is useful to generate messages into the output for each single line in the input.

EXAMPLE

Print the first two lines and the last two lines of the input

        ; seq 15 | rf | lns -u -r ,2 -r -2,
        1
        2
        14
        15
        

Apply cmd to each line of Go sources files

        ; lf -g ,~*.go | lns | for x {
            cmd $x
        }
        

SOURCE

  • /zx/sys/src/clive/cmd/lns


User's manual. Section 1.