AWK – Unary Operators

  • Post author:
  • Post category:AWK
  • Post comments:1 Comment
AWK - Unary Operators

This topic is about 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

In this topic we learned about AWK – Unary Operators. To know more, Click Here.

This Post Has One Comment

Leave a Reply