Next: , Up: recsel


20.1 recsel Invocation

recsel searches rec files for records satisfying a certain criteria. Synopsis:

     recsel [option]... [-n indexes | -e record_expr | -q str | -m num] [-c | (-p|-P|-R) field_expr] \
            [file]...

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

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.

The following global options are available.

-C
--collapse
Do not section the result in records with newlines.
-d
--include-descriptors
Print record descriptors along with the matched records
-s secret
--password=secret
Try to decrypt confidential fields with the given password.
-S
--sort=field
Sort the output by field. This option has precedence to whatever sorting criteria is specified in the corresponding record descriptor with %sort.
-U
--uniq
Remove duplicated fields in the output records. Fields are duplicated if there are more than one featuring the same field name and the same value.

The selection options are used to select a subset of the records in the input.

-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
--expression=expr
A record selection expression (see Selection Expressions). Only the records matched by the expression will be taken into account to compute the output.
-q str
--quick=str
Select records having a field whose value contains the substring str.
-m num
--random=num
Select num random records. If num is zero then select all the records.
-t TYPE
--type=type
Select records of a given type only.

The output options are used to determine what information about the selected records to display to the user, and how to display it.

-p name_list
--print=name_list
List of fields to print for each record. name_list is a list of field names separated by commas. For example:
          -p Name,Email

means to print the Name and the Email of every matching record.

If this option is not specified then all the fields of the matching records are printed in the standard output.

-P name_list
--print-values=name_list
Same than ‘-p’, but print the values of the selected fields.
-R name_list
--print-row=name_list
Same than ‘-P’, but print the values separated by single spaces instead of newlines.
-c
--count
If this option is specified then recsel will print the number of matching records instead of the records themselves. This option is incompatible with -p, -P and -R.

Some special options are available to ease the communication between the recutils and other programs, such as lisp interpreters. Those options are not intended to be used by human operators.

--print-sexps
Print the data using sexps instead of rec format.