NAME

line - Greple module to produce result by line numbers

SYNOPSIS

greple -Mline

DESCRIPTION

This module allows you to use line numbers to specify patterns or regions which can be used in greple options.

-L=line numbers

Simply, next command will show 200th line with before/after 10 lines of the file:

greple -Mline -L 200 -C10 file

If you don't like lines displayed with color, use --nocolor option or set colormap to something do nothing like --cm=x.

Multiple lines can be specified by joining with comma:

greple -Mline -L 10,20,30

It is ok to use -L option multiple times, like:

greple -Mline -L 10 -L 20 -L 30

But this command produce nothing, because each line definitions are taken as a different pattern, and greple prints lines only when all patterns matched. You can relax the condition by --need 1 option in such case, then you will get expected result. Note that next example will display 10th, 20th and 30th lines in different colors.

greple -Mline -L 10 -L 20 -L 30 --need 1

Range can be specified by colon:

greple -Mline -L 10:20

You can also specify the step with range. Next command will print all even lines from line 10 to 20:

greple -Mline -L 10:20:2

Any of them can be omitted. Next commands print all, odd and even lines.

greple -Mline -L ::		# all lines
greple -Mline -L ::2	# odd lines
greple -Mline -L 2::2	# even lines

If start and end number is negative, they are subtracted from the maxmum line number. If the end number is prefixed by plus (`+') sign, it is summed with start number. Next commands print top and last 10 lines respectively.

greple -Mline -L :+9	# top 10 lines
greple -Mline -L -9:	# last 10 lines

Next example print all lines of the file, each line in four different colors.

greple -Mline -L=1::4 -L=2::4 -L=3::4 -L=4::4 --need 1

If forth parameter is given, it describes how many lines is included in that step cycle. For example, next command prints top 3 lines in every 10 lines.

greple -Mline -L ::10:3

When step count is omitted, forth value is used if available.

L=line numbers

This notation just define function spec, which can be used in patterns, as well as blocks and regions. Actually, -L=line is equivalent to --le L=line.

Next command show patterns found in line number 1000-2000 area.

greple -Mline --inside L=1000:+1000 pattern

Next command prints all 10 line blocks which include the pattern.

greple -Mline --block L=:::10 pattern

This module implicitly set -n option. Use --no-line-number option to disable it.

Using this module, it is impossible to give single L in command line arguments. Use like --le=L to search L. You have a file named L? Stop substitution by placing -- before target files.

SEE ALSO

Getopt::EX::Numbers