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

Dot precision as modifier

A dot/period followed by an integer indicates the precision to use when printing. The meaning of precision differs by control letter:

  • %d, %i, %o, %u, %x, and %X: Minimum number of digits to print in output
  • %e, %E, %f, and %F: Number of digits to print on the right of the decimal point in output
  • %g and %G: Prints the maximum number of significant digits in output
  • %s: Prints maximum number of characters from the string that should print

The following example shows how a dot is used as modifier for format control character. We will use a number 201.33 and print it using .1 and .4 dot precision with different format control characters as follows:

$ vi printf_precision.awkBEGIN    {    print "====Using .1 precision===="

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