AWK - Unary Operators



AWK supports the following unary operators −

Unary Plus

It is represented by +. It multiplies a single operand by +1.

Example

[jerry]$ awk 'BEGIN { a = -10; a = +a; print "a =", a }'

On executing this code, you get the following result −

Output

a = -10

Unary Minus

It is represented by -. It multiplies a single operand by -1.

Example

[jerry]$ awk 'BEGIN { a = -10; a = -a; print "a =", a }'

On executing this code, you get the following result −

Output

a = 10
awk_operators.htm
Advertisements