O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exponential expressions

There are two formats of exponential operators:

Exponential format 1 (^):

This is an exponential operator that raises the value of an operand. For example, the following example raises the value of 5 by the power of 3:

$ awk 'BEGIN { a = 5; a = a ^ 3; print "a ^ 3 =",a }'

The output on execution of the preceding code is as follows:

a ^ 3 = 125 

Exponential format 2 (**):

This also raises the value of an operand. For example, the following example raises the value of 5 by the power of 3:

$ awk 'BEGIN { a = 5; a = a ** 3; print "a ** 3 =",a }'

The output on execution of the preceding code is as follows:

a ** 3 = 125

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required