Skip to content
Copy range of lines from stdin to stdout.
Branch: master
Clone or download
Pull request Compare This branch is 62 commits ahead, 46 commits behind nickolasburr:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.travis.yml
CHANGELOG.md
LICENSE.md
Makefile
Makefile.msvc
README.md
rng.1
rng.c
tester.c

README.md

rng

Copy ranges of lines from standard input to standard output.

Synopsis

rng range ...

Description

rng copies the specified line ranges from standard input to standard output. Ranges can be specified as follows:

Syntax Meaning
from:to Line from through to (inclusive).
from: Line from to end of input.
:to Start of input to line end (inclusive).
: The entire input.
line Line line only.

Line numbers go up from 1 relative to the start of input, and down from -1 relative to the end of input.

Use of negative line numbers, overlapping ranges, or backtracking ranges causes the file to be buffered in its entirety.

Examples

Output lines 2-5 of a file:

rng 2:5 <file.txt

Output the first three, fifth, and last three lines of a file:

rng :3 5 -3: <file.txt

Output a file twice:

rng : : <file.txt

Building

Unix-likes:

make

# optionally
make test
make install
make uninstall

Visual C++, from the Developer Command Prompt:

nmake /f Makefile.msvc

Authors

Originally by Nickolas Burr (nickolasburr@gmail.com). Rewritten by Sijmen J. Mulder (ik@sjmulder.nl).

You can’t perform that action at this time.