This command selects records that matches the range specified at c= with the values in the column specified at the f= parameter. Various selection criteria can be specified as arguments in the parameters as follows. Use msel command to query complex selection criteria such as matching against a combination of string characters. For more information about OR, AND conditions for key field, refer to mselstr command.
Range types include open range, closed range, inclusive and exclusive bounds and infinite range.
c=specify multiple range and select records that matches either range (OR condition).
f=specify multiple fields at which the values matches either range (OR condition).
f=change the logical operator from OR to AND with the -F option.
k=specify key value as the selection unit.
Use AND logical operator to select records based on the key value with the -R option.
Typical examples are shown in 3.16 to 3.18.
Table 3.16: Input Data
Table 3.17: Select rows if the values in the val column falls on the range of 1 to 3 mselnum f=val c='[1,3]' |
||||||||||
key val a 1 b 3 |
Table 3.18: Select rows in val field with values greater than or equal to 1 but less than 3 mselnum f=val c='[1,3)' |
||||
key val a 1 |
key |
val |
b |
6 |
Table 3.19: Select rows less than or equal to 1 or greater than or equal to 5 mselnum f=val c='(,1],[5,)' |
||||||||
key val a 1 a -3 b 6 |
mselnum f= c= [k=] [u=] [-F] [-r] [-R] [i=] [o=] [bufcount=] [-nfn] [-nfno] [-x] [-q] [--help] [--version]
f= Field name of target query (allow multiple fields). c= Select row(s) where the data array specified at f= parameter matches with the specified range at this parameter (allow multiple ranges). k= Key field(s) as unit of selection (Multiple range can be specified). o= Records matching the condition will be printed to this output file. u= Records that do not match the condition will be printed to this output file. -F Select all records that matches the defined value if multiple items are defined at f= parameter. -r Reverse selection Select records excluded from the selection condition. -R Select if all rows with the same key specified at k= parameter matches the criteria.
Select rows where val is greater than 2 and below 5, i.e. records matching id=2,5 are selected.
$ more dat1.csv id,val 1,5.1 2,5 3,-2.0 4, 5,2.0 $ mselnum f=val c='[2,5]' i=dat1.csv o=rsl1.csv #END# kgselnum c=[2,5] f=val i=dat1.csv o=rsl1.csv $ more rsl1.csv id,val 2,5 5,2.0
Select rows where val is greater than 2, i.e. records where id=1,2,5.
$ mselnum f=val c='[2,]' i=dat1.csv o=rsl2.csv #END# kgselnum c=[2,] f=val i=dat1.csv o=rsl2.csv $ more rsl2.csv id,val 1,5.1 2,5 5,2.0
msel : Selection of records by conditional expressions.
mselstr : Selection by string matching.