RAC - Specification

rac

RAC Specification, Version 1, Copyright © 2003-2004
Aurélio Marinho Jargas, Thobias Salazar Trevisan

NAME

rac - Rows And Columns, the text extraction tool

SYNOPSIS

rac address [file]...

DESCRIPTION

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.

OPTIONS

The rac utility supports the XBD specification, Utility Syntax Guidelines.
-h, --help
Prints help information and exit
-V, --version
Prints program version and exit

OPERANDS

The following operands are supported:
file
A pathname of a file whose contents will be read and extracted. If no file operands are specified, the standard input will be used.
address
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.

STDIN

The standard input will be used only if no file operands are specified. See the INPUT FILES section.

INPUT FILES

The input files must be text files.

ENVIRONMENT VARIABLES

None.

ASYNCHRONOUS EVENTS

Default.

STDOUT

The pieces of input file that matches the specified addresses are written to standard output.

STDERR

Used only for diagnostic messages.

OUTPUT FILES

None.

EXTENDED DESCRIPTION

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 https://aurelio.net/rac.

EXIT STATUS

The following exit values are returned:
0
Successful completion.
>0
An error occurred.

CONSEQUENCES OF ERRORS

Default.

APPLICATION USAGE

Addresses are not line based as other UNIX tools. The specified order matters, repetition and interpolation are allowed.

EXAMPLES

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

FUTURE DIRECTIONS

None.

SEE ALSO

head, tail, rev, tac, cut, sed.