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

17.2 recsel

recsel reads the given rec files (or the data in the standard input if no file is specified) and prints out records (or part of records) based upon some criteria specified by the user.

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

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

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.

Make strings case-insensitive in selection expressions.
Do not section the result in records with newlines.
Print record descriptors along with the matched records
-s secret
Try to decrypt confidential fields with the given password.
Sort the output by the comma separated list of fields names fields. This option has precedence to whatever sorting criteria is specified in the corresponding record descriptor with %sort.
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.
Group the output records by the provided comma separated set of fields. Note that grouping is performed before sorting.

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
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
Select records having a field whose value contains the substring str.
-m num
Select num random records. If num is zero then select all the records.
-t type
Select records of a given type only.
-j field
Perform an inner join of the record set selected in -t and the record set for which field is a foreign key. field must be a field declared with type rec and thus must be a foreign key. If a join is performed then any selection expression and field expression operate on the joined record sets.

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
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
Same than ‘-p’, but print the values of the selected fields.
-R name_list
Same than ‘-P’, but print the values separated by single spaces instead of newlines.
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 the data using sexps instead of rec format.