READINFO(1)

NAME
readinfo - read fields from a relational

SYNOPSIS
readinfo [ -a ] [ -i filename ] [ -o filename ] [ -L ] fieldname ...

DESCRIPTION
Reads a formatted table in a relational format with named fields. Input is from stdin unless the -i is specified. Output is to stdout unless the -o option is specified. The -a option specifies output should be appended to the output file instead of overwriting the output file. The -L option specifies line numbers shoudl be prepended to each output line.

The file is described by a special comment or meta command which defines the field names and any prefixes or suffixes to add to each field. The following is a simple example which illustrates the usage.

#
# short readinfo example
#FIELDS GLOBAL null=X no=. domain suffix=.tic.com ip prefix=192.135.128.
akasha             129
xfr                133
oak.zilker.net.    .198.252.182.129

The special #FIELDS comment (can also be specified as $FIELDS) describes each field in the file. Field descriptions appear in the order the appear in the file. There is no whitespace between the '#' and the 'FIELDS'. 'FIELDS' must be all uppercase.

In this example two fields with the names "domain" and "ip" are defined. The special field "GLOBAL" defines global parameters which apply to all fields in the file. Each field description is the name of the field which can be any arbitrary name followed by optional field parameters which are keyword=value pairs. The field parameters and their semantics are:

null=<string>
    Sets the empty field value to the <string>. Whenever <string> appears as a field value, readinfo emits an empty value for the field.

prefix=<string>
    Adds a prefix of <string> to each field value output.

suffix=<string>
    Adds a suffix of <string> to each field value output.

no=<character>
    Does not add a prefix or suffix to the field value whenever <character> either starts or ends the string respectively.

Only fields listed on the command line are output to stdout. For example the command

    readinfo domain ip <example
produces the following output

    akasha.tic.com	192.135.128.129
    xfr.tic.com	192.135.128.133
    oak.zilker.net	198.252.182.129

Each emitted field value is separated by a single TAB characters. The command

    readinfo ip <example

produces the following output

    192.135.128.129
    192.135.128.133
    198.252.182.129

Fields are emitted in the order they appear on the command line. Fields may be duplicated by putting their names multiple times on the command line.

Field values may be any ASCII character except for a TAB. Spaces may be inserted in a field by escaping the space character with a backslash or by quoting the entire field value in either single or double quotes. A line may extend across multiple input lines by ending each line except the last line with a backslash.

A comment which starts with #INCLUDE (or $INCLUDE) allows including input from an alternate file. The filename is specified after the #INCLUDE. After the alternate file is read, input resumes from the file with the #INCLUDE directive.

A generator allows the generation of multiple lines of output by specifying them in a single line. A generator takes the form of:

    #GENERATOR <name> <start>,<end>,<inc>
    #END

Generators may not be nested in the current implementation.  Whenever
<name> appears within curly brackets within the GENERATO construct, it is
replaced with the current loop value.

An example of a GENERATOR is:

    #FIELDS host suffix=.tic.com ip prefix=192.168.128.
    #GENERATOR num 97,102,1
    dhcp-{num}      {num}
    #END

THis produces the output:

    dhcp-97.tic.com  192.168.128.97
    dhcp-98.tic.com  192.168.128.98
    dhcp-99.tic.com  192.168.128.99
    dhcp-100.tic.com 192.168.128.100
    dhcp-101.tic.com 192.168.128.101
    dhcp-102.tic.com 192.168.128.102
    casa-pc.tic.com  192.168.128.254