Relational expressions
Relational expressions are built using relational operators, also known as conditional or comparison operators.These operators are used to test conditions, like if
or while
. Relational expressions compare strings or numbers for relationships such as equality, greater than , less than, and so on.
These expressions return 1 if the condition evaluates to true and 0 if false. When comparing operands of different types, numeric operands are converted to strings using a built-in variable (using CONVFMT
). Strings are compared character to character.
Equal to (==):
This relational operator is represented by the equals symbol repeated twice (==
).It returns true if both operands are equal; otherwise it returns false.Here, we have to make sure not to mistype the==
operator by forgetting to put one=
character. In this case, the AWK code still remains valid but the program does not do what it was intended to do, resulting in a semantic error. Syntactically, the program will be correct...