NF != 3 { print $0, "number of fields is not equal to 3" } $2 < 3.35 { print $0, "rate is below minimum wage" } $2 > 10 { print $0, "rate exceeds $10 per hour" } $3 < 0 { print $0, "negative hours worked" } ...
The relational operators < (less than), > (greater than), <= (less than or equal to), >= (greater than or equal to), = = (equal to), and ! = (not equal to) can be used to form patterns. For example, the pattern: $1 < $4 matches records where the first field is less ...
>=– greater than or equal to <=– less than or equal to ==– equal to !=– not equal to some_value ~ / pattern/– true if some_value matches the pattern some_value !~ / pattern/– true if some_value does not match the pattern Now that we have looked at the various comparison...
The next examples show a pattern as a conditional statement (numeric or string). Each record is tested to see if the conditional is true for that record. If it is true, the ACTION (printing, in this case) is taken on that record. In the second example, an ACTION is not listed, so ...
Thus, if IGNORECASE is not equal to zero, /aB/ matches all of the strings "ab", "aB", "Ab", and "AB". As with all AWK variables, the initial value of IGNORECASE is zero, so all regular expression and string operations are normally case-sensitive. Under Unix, the full ISO 8859-1...
!= Not equal to ~ Matches 匹配 !~ Does not match 不匹配 NF == 5 NF(每个输入记录的字段数)的值和5相比较,如果结果为真,那 么就进行相应的处理,否则不进行处理。 $5 ~ /MA/ {print $1 “,”$6} 注意:关系操作符==和赋值操作符=是不同的 ...
x <= yTrue if x is less than or equal to y. x > yTrue if x is greater than y. x >= yTrue if x is greater than or equal to y. x == yTrue if x is equal to y. x != yTrue if x is not equal to y. x ~ yTrue if the string x matches the regexp denoted by y....
If string is null, the array has no elements. (So this is a portable way to delete an entire array with one statement. See Delete.)If string does not match fieldsep at all (but is not null), array has one element only. The value of that element is the original string. ...
x <= y Trueif x is less than or equal to y. x > y Trueif x is greater than y. x >= y Trueif x is greater than or equal to y. x == y Trueif x is equal to y. x != y Trueif x is not equal to y. x ~ y Trueif the string x matches the regexp denoted by y....
Thus, if IGNORECASE is not equal to zero, /aB/ matches all of the strings "ab", "aB", "Ab", and "AB". As with all AWK variables, the initial value of IGNORECASE is zero, so all regular expression and string operations are normally case-sensitive. Under Unix, the full ISO 8859-1...