Next: , Up: recins

21.1 recins Invocation

recins adds new records to a rec file or to rec data read from the standard input. Synopsis:

     recins [option]... [t type] [-n indexes | -e expr | -q str | -m num] \
            [(-f str -v str]|[-r recdata)]... [file]

The new record that will be inserted by the command is constructed by using pairs of ‘-f’ and ‘-v’ options. Each pair defines a field. The order of the parameters is significant.

If no FILE is specified then the command acts like a filter, getting the data from the standard input and writing the result in the standard output.

If the specified FILE does not exist, it is created.

In addition to the common options described earlier (see Common Options) the program accepts the following options.

The type of the new record. If there is a record set in the input data matching this type then the new record is added there. Otherwise a new record set is created. If this parameter is not specified then the new record is anonymous.
Declares the name of a field. This option shall be followed by a ‘-v’.
The value of the field being defined.
Add the fields of the record in value. This option can be intermixed with -f ... -v pairs.
Encrypt confidential fields with the given password.
Don't use external record descriptors.
Be verbose when reporting integrity problems.
Don't generate auto fields. See %auto.

Record selection arguments are supported as well. If they are used then recins enters in “replacement mode”. Instead of appending the new record, matched records are replaced by copies of the provided record. The selection arguments are summarized in the next table.

-n indexes
Match the records occupying the given positions in its record set. indexes must be a comma-separated list of numbers or ranges, the ranges being two numbers separated with dashes. For example, the following list denotes the first, the third, the fourth and all records up to the tenth: -n 0,2,4-9.
-e expr
A record selection expression (see Selection Expressions). Matching records will get replaced.
-q str
Remove records having a field whose value contains the substring str.
-m num
Select num random records. If num is zero then all records are selected, i.e. no replace mode is activated.
Make strings case-insensitive in selection expressions.