Next: , Previous: Invoking recsel, Up: Invoking the Utilities


17.3 Invoking recins

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

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

The new record to be inserted by the command is constructed by using pairs of ‘-f’ and ‘-v’ options, or ‘-r’. 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 standard input and writing the result to 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.

-t
--type=expr
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.
-f
--field=name
Declares the name of a field. This option must be followed by a ‘-v’.
-v
--value=value
The value of the field being defined.
-r
--record=value
Add the fields of the record in value. This option can be intermixed with ‘-f ... -v’ pairs.
-s
--password
Encrypt confidential fields with the given password.
--no-external
Don't use external record descriptors.
--verbose
Be verbose when reporting integrity problems.
--no-auto
Don't generate auto fields. See Auto-Generated Fields.

Record selection arguments are supported too. If they are used then recins uses “replacement mode”: instead of appending the new record, matched records are replaced by copies of the provided record. The selection arguments are the same as in recsel:

-n indexes
--number=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 record_expr
--expression=expr
A record selection expression (see Selection Expressions). Matching records will get replaced.
-q str
--quick=str
Remove records having a field whose value contains the substring str.
-m num
--random=num
Select num random records. If num is zero then all records are selected, i.e. no replace mode is activated.
-i
--case-insensitive
Make strings case-insensitive in selection expressions.
--force
Insert the requested record even in potentially dangerous situations, such as when the data integrity of the database is compromised.