RAC Specification, Version 1, Copyright © 2003-2004
Aurélio Marinho Jargas, Thobias Salazar Trevisan
rac - Rows And Columns, the text extraction tool
rac address [file]...
The rac utility is a text extractor that reads one input file and
grab pieces of it, writing them to standard output. The pieces are
defined by addresses, obtained from the address operand string.
The rac utility supports the XBD specification,
Utility Syntax Guidelines.
- -h, --help
Prints help information and exit
- -V, --version
Prints program version and exit
The following operands are supported:
A pathname of a file whose contents will be read and extracted. If
no file operands are specified, the standard input will be used.
A string to be used as the address of the desired text to be
extracted. The application must not present an address that
violates the restrictions of a text file except that the final
character need not be a newline character.
The standard input will be used only if no file operands are
specified. See the INPUT FILES section.
The input files must be text files.
The pieces of input file that matches the specified addresses are
written to standard output.
Used only for diagnostic messages.
Rac is a GPL text extraction tool. It reads a file (or STDIN) and
return the text that matches the specified address. This address is
composed by lines, columns, or a combination of them. Different from
other UNIX tools, rac is char based, not line.
Ranges, reverse count, step and repetition are allowed. The address
'1; 3; 5:7; 1; 6:4; -1' applied on a 10 lines text returns these
lines: 1 3 5 6 7 1 6 5 4 10 (the specified order is preserved).
It is useful to extract arbitrary text lines and/or columns, or
complicated ranges as: from line 10 column 13 to line 15 column 4.
Please read the complete addressing specification.
Please visit the program homepage at
The following exit values are returned:
An error occurred.
CONSEQUENCES OF ERRORS
Addresses are not line based as other UNIX tools. The specified order
matters, repetition and interpolation are allowed.
- Get the 3rd line
$ rac '3' file.txt
- Get from the 3rd to the 5th line, including
$ rac '3:5' file.txt
- Get the last line (tail -1)
$ rac '-1' file.txt
- Get the last 10 lines (tail)
$ rac '-10:-1' file.txt
- Get the first 10 columns of each line (cut -c1-10)
$ rac '[1:10]' file.txt
- Get the last char of each line
$ rac '[-1]' file.txt
- Invert lines of file (tac)
$ rac '-1:1' file.txt
- Invert columns of lines (rev)
$ rac '[-1:1]' file.txt