To use the record selection option, specify the selection field (selection condition).
Two or more selection fields can be specified. When two or more selection fields are delimited by the comma (,), it becomes the logical product of the selection condition. When two or more Selection field options (-p) are specified, it becomes the logical add of the selection condition.
Format
-p sel-def [ ,sel-def ...]
Format 1 of sel-def
pos.len typ [ opt ] .cmp.pos.len typ
For the format 1 of sel-def, two selection fields are compared. The left side of cmp shows the compared field and the right side shows the comparing field. An error occurs when the field to be compared or the comparing field does not exist on the input record.
Format 2 of sel-def
pos.len typ [ opt ] .cmp.self
For the format 2 of sel-def, the selection field is compared with a literal value. The left side of cmp shows compared field and the right side shows a literal value. An error occurs when the field to be compared does not exist on the input record.
pos
This specifies the position of the compared field or the comparing field.
To specify the binary files and text file fixed fields, specify the byte position where the head of the record was assumed to be 0. For the text file floating field, text file CSV format, and text file TSV format, specify the field number counted from 0.
len
This specifies the length of the compared field or the comparing field in the number of byte.
For the text file floating field specification, text file CSV format, and text file TSV format, process with the length specified here when the actual fields are longer than the specified field length. When the actual fields are shorter than the specified field length, the actual field length is processed.
To specify an unsigned binary number for the data format, specify mask values. Compare the logical product of the mask value and field values. The mask value specifies the same value as the compared field and the comparing field.
For information about the lengths of each data format, refer to the Data formats that can be specified in the compared field and the comparing field.
Note
In text file CSV format and text file TSV format specification, the length of the compared field or the comparing field does not contain double quotation marks (") that enclose the field. When two consecutive double quotation marks ("") are included in the field, they are interpreted as one double quotation mark (").
Example: Compared field and length in text file CSV format
Compared field Characters effective as compared field Length of compared field ABC ABC 3bytes "ABC" ABC 3bytes "A""B""C" A"B"C 5bytes "A,B,C" A,B,C 5bytes
self
This specifies the literal values. The description form of self is shown below.
Format 1 of self
'Character string'
Specifies the character string for the format 1 of self.
Format 2 of self
xHexadecimal number
Specifies the hexadecimal number for the character string for the format 2 of self.
Format 3 of self
dDecimal number
Specifies the decimal number for numeric or number for the format 3 of self.
Note
The description method when a literal value is specified is different according to the shell used. The description example in a typical shell is shown below. When a literal value is specified for the argument file (argument file option (-a)), it is same as the method of describing the Bourne shell.
Bourne Shell
To specify a character string with a command argument, enclose the entire argument as shown below.
Example) When you specify character string "ABC"
-p "0.3asc.eq.'ABC'"
To specify a character string including a double quotation (") with a command argument, specify a backslash (\) immediately before the double quotation (").The character with a special meaning as a shell is similar. (example: $, \, `)
Example) When you specify character string ""ABC""
-p "0.5asc.eq.'\"ABC\"'"
To insert a quotation (') into a character string, specify two quotations in succession.
Example) When you specify character string "'ABC'"
-p "0.5asc.eq.'''ABC'''"
C shell
The backslash (\) is specified before quotation (') before and behind the character string when the character string of a literal value is specified.
Example) When you specify character string "ABC"
-p 0.3asc.eq.\'ABC\'
The backslash (\) is specified before double quotation (") when the character string of a literal value which contains double quotation (") is specified. The character with a special meaning as a shell is similar. (example: $, &, (, ), |, \, `, {, }, ;, *, <, >, ?, blank)
Example) When you specify character string ""ABC""
-p 0.5asc.eq.\'\"ABC\"\'
When the character string of a literal value which contains quotation (') is specified, it is continued two specification of the backslash (\) before quotation (').
Example) When you specify character string "'ABC'"
-p 0.5asc.eq.\'\'\'ABC\'\'\'
When the character string of a literal value is specified, the character string should be one character or more.
When you specify a decimal number of a literal value, signs can be specified.
Literal value is compared after adjusting to the data format of the compared field.
When you specify a text file fixed field, literal values cannot contain record separation character.
When you specify a text file floating field, literal values cannot contain field separation character or record separation character.
For text file CSV format and text file TSV format, double quotation marks (") do not need to enclose literal values.
When specifying literal value of fixed-point binary numbers, unsigned fixed-point binary numbers, fixed-point binary numbers - little endian, unsigned fixed-point binary numbers - little endian, fixed-point binary numbers - system dependent, and unsigned fixed-point binary numbers - system dependent as decimal numbers, a literal value can specify even the value expressible by 16 bytes.
typ
This specifies the data formats of the compared field and the comparing field.
For more information, refer to the Data formats that can be specified in the compared field and the comparing field.
Note
When the data format of the compared field and comparing field are different, it compares the data after adjusting them to the data format of the compared field.
When the data format of the compared field is character, it compares data in the shorter length of the compared field and comparing field.
When the data format of the compared field is numeric or number, the shorter field of the compared field and comparing field are compared with the longer one after moving to the right end.
In the binary file processing, when Input code system option (-q) is excluding EBCDIC, ASCII code can be specified.
In the text file processing, when Input code system option (-q) is ASCII, ASCII code can be specified.
When the Input code system option (-q) is EBCDIC, EBCDIC code can be specified.
When the Input code system option (-q) is ASCII, and C or EUC locale is defined in the LANG environment variable, EUC, EUC 2 byte process codes, and EUC 4 byte process codes can be specified.
Unicode UCS-2 form can be specified, except when the Input code system option (-q) is EBCDIC at the binary file. When the Input code system option (-q) is Unicode (UCS-2 form), the Unicode UCS-2 form can be specified in case of the text file. In both cases, when C or UTF-8 locale is defined in the LANG environment variable, the Unicode UCS-2 form can be specified.
Unicode UTF-32 form can be specified, except when the Input code system option (-q) is EBCDIC at the binary file. When the Input code system option (-q) is Unicode (UTF-32 form), the Unicode UTF-32 form can be specified in case of the text file. In both cases, when C or UTF-8 locale is defined in the LANG environment variable, the Unicode UTF-32 form can be specified.
Unicode UTF-8 form can be specified, except when the Input code system option (-q) is EBCDIC at the binary file. When the Input code system option (-q) is Unicode (UTF-8 form), the Unicode UTF-8 form can be specified in case of the text file. In both cases, when C or UTF-8 locale is defined in the LANG environment variable, the Unicode UTF-8 form can be specified.
opt
This specifies the operations of the compared field.
To specify two or more operations, describe them successively. "l" can be specified for binary files. All the operations can be specified for the text file. The operations that can be specified are shown below.
opt | Meaning |
---|---|
b | Blanks and tabs in the head of the field are disregarded. |
d | Only the blank and the alphanumeric character are compared. |
i | Control character codes are disregarded. |
j | Lowercase letters are compared as uppercase letters. |
l | Compares according to the collating sequence defined in LC_COLLATE environmental variable. Only when the data format is ASCII code, EUC, EUC 2 byte process codes, EUC 4 byte process codes or Unicode and the Input code system (-q) is ASCII code system or Unicode system, this option can be specified. It is in the exclusive relationship with "n". |
n | Character strings of the numbers that contains signs are compared with arithmetic value. It can be specified only for text files. The result is not guaranteed when characters other than the numbers exist in the character string. When the data format is ASCII code or Unicode, it can be specified. It is in the exclusive relationship with "l". |
Note
If modify collation sequence is specified as the data format of the compared field or comparing field, field operations cannot be specified in opt.
cmp
This specifies the comparison operator.
The following shows comparison operators and their meanings.
cmp | Meaning(True condition) |
---|---|
eq | Compared field = Comparing field or literal value |
ne | Compared field != Comparing field or literal value |
gt | Compared field > Comparing field or literal value |
ge | Compared field >= Comparing field or literal value |
lt | Compared field < Comparing field or literal value |
le | Compared field <= Comparing field or literal value |
Note
When the compared field is EUC, EUC 2 byte process codes and EUC 4 byte process codes, the data is compared in the collating sequence according to the environment variable LC_COLLATE.
Example
To select records that the field of packed decimal number in 4 bytes from the 32nd byte and the field of the external decimal number in 4 bytes from the 12th byte are equal, specify as follows.
-p 11.4zdl.eq.31.4pdl
To select records that have more than 30 fields of the fixed-point binary number in 4 bytes from the 12th byte, specify as follows.
-p 11.4fbi.ge.d30
To select records that have less than -1000 fields of the external decimal number in 4 bytes from the 10th byte, specify as follows.
-p 9.4zdl.lt.d-1000
To select the record in which the character string 'abcde' exists in the field of ASCII code in 5 bytes from the 10th byte, specify as follows.
For Bourne shell
-p "9.5asc.eq.'abcde'"
For C shell
-p 9.5asc.eq.\'abcde\'
To select the record in which the character string 'ab"cd' exists in the field of ASCII code in 5 bytes from the 10th byte, specify as follows.
For Bourne shell
-p "9.5asc.eq.'ab\"cd'"
For C shell
-p 9.5asc.eq.\'ab\"cd\'
To select the record in which the character string 'abc'd' exists in the field of ASCII code in 5 bytes from the 10th byte, specify as follows.
For Bourne shell
-p "9.5asc.eq.'abc''d'"
For C shell
-p 9.5asc.eq.\'abc\'\'d\'
To select the record in which the character string 'abc' exists in the field of ASCII code in 3 bytes from the 4th byte and character string 'abc' in the field of ASCII code in 3 bytes from the 10th byte, the record in which the character strings 'abcde' in the field of ASCII code in 5 bytes from 4th byte, specify as follows.
For Bourne shell
-p "3.3asc.eq.'abc'","9.3asc.eq.'abc'" -p "3.5asc.eq.'abcde'"
For C shell
-p 3.3asc.eq.\'abc\',9.3asc.eq.\'abc\' -p 3.5asc.eq.\'abcde\'