Dselect - Selection by a conditional expression

[ English | Japanese ]

[visit D-home]

SYNOPSIS

Dselect [ options ] Dl-expression [ input-file.. ]
Dselect [ options ] [ -f Dl-expression-file ].. [ input-file.. ]

DESCRIPTION

Dselect reads records from the input-files evaluating the Dl-expression, and when the result is TRUE, copies the input record to the standard output.

See the manual of Dl for the Dl-expression. The restriction for Dl-expression used in Dselect is that no modification of the input record or output to the file is allowed.

OPTIONS

-f Dl-expression-file
Dl-expression is not taken from the command argument but from the Dl-expression-file. This option is repeatable. When repeated, expression files are concatenated to form an expression.
-F
adds "filename" field to each output record; value is the input file name in the form of the command arguments after globbed by the shell. This field is not added when the input file is the standard input.
-D [i/o]datautf=8|16|32
UTF I/O feature (see manual page of UTF I/O feature.)

FIXED NAME FIELDS

filename:
at the top of each record, when -F option is specified..

ENVIRONMENT

Ddatautf, Didatautf, Dodatautf
for UTF I/O feature.

EXAMPLES

Field "count" value is greater than 1:

Dselect count:n ">" 1
Dselect NUM FIELD count GT 1

(Above examples produce same result. Note that :n or NUM is required.)

Field "keywd" values have character string "database" or "DB" in it:

Dselect keywd =~ database OR keywd =~ DB

Same condition:

Dselect keywd =~ "{" database DB "}"

All of field "keywd" values are alphabet only words, starting with a capital letter, followed by small lettters:

Dselect NOT keywd UNLIKE "^[A-Z][a-z]+$"

(UNLIKE tests if there is at least one such value.)

Field "mark" value (exists at most one) has value *:

Dselect mark == CONST "*"

(You need CONST because "*" is a reserved word.)

Field "mark" value (exists at most one) has value + or *:

Dselect "{" "+" "*" "}" INCL FIELD mark

(Keyword FIELD is mandatory. Without it, "mark" becomes a constant.)

Extracting a record from every 100 records:

Dselect REC# % 100 == 1

Case insensitive search:

Dselect CAPS keywd =~ TOKYO

DIAGNOSTICS

See the manual of D_msg.

SEE ALSO

Dintro, Dextract, Dgrep, Dhead, Dtail, Dl, Ded, D_msg.

AUTHOR

MIYAZAWA Akira


miyazawa@nii.ac.jp
2003-2007