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

Numeric constants

A numeric constant stands for a number. It can be an integer, a decimal fraction, or a number in an exponential notation. Some examples of numeric constant values are as follows:

  • 100
  • 1.10
  • 1.05e+2
  • 1.05e-1

Any nonzero numeric value in AWK is true in the case of expression evaluation, and zero is false. For example:

$ vi numeric.awkBEGIN{if ( 1 )    print "numeric 1 "if ( 1.234 )    print "numeric 1.234"if ( 1.234e )    print "numeric 1.234e"if ( 0 )    print "false"} $ awk -f numeric.awk

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

numeric 1 numeric 1.234numeric 1.234e

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