http://www.usf.uos.de/infoservice/doc/

(gawk.info)Control Letters


Next: Format Modifiers Prev: Basic Printf Up: Printf
Enter node , (file) or (file)node

Format-Control Letters
----------------------

   A format specifier starts with the character `%' and ends with a
"format-control letter"; it tells the `printf' statement how to output
one item.  (If you actually want to output a `%', write `%%'.)  The
format-control letter specifies what kind of value to print.  The rest
of the format specifier is made up of optional "modifiers" which are
parameters to use, such as the field width.

   Here is a list of the format-control letters:

`c'
     This prints a number as an ASCII character.  Thus, `printf "%c",
     65' outputs the letter `A'.  The output for a string value is the
     first character of the string.

`d'
`i'
     These are equivalent. They both print a decimal integer.  The `%i'
     specification is for compatibility with ANSI C.

`e'
`E'
     This prints a number in scientific (exponential) notation.  For
     example,

          printf "%4.3e\n", 1950

     prints `1.950e+03', with a total of four significant figures of
     which three follow the decimal point.  The `4.3' are modifiers,
     discussed below. `%E' uses `E' instead of `e' in the output.

`f'
     This prints a number in floating point notation.  For example,

          printf "%4.3f", 1950

     prints `1950.000', with a total of four significant figures of
     which three follow the decimal point.  The `4.3' are modifiers,
     discussed below.

`g'
`G'
     This prints a number in either scientific notation or floating
     point notation, whichever uses fewer characters. If the result is
     printed in scientific notation, `%G' uses `E' instead of `e'.

`o'
     This prints an unsigned octal integer.  (In octal, or base-eight
     notation, the digits run from `0' to `7'; the decimal number eight
     is represented as `10' in octal.)

`s'
     This prints a string.

`x'
`X'
     This prints an unsigned hexadecimal integer.  (In hexadecimal, or
     base-16 notation, the digits are `0' through `9' and `a' through
     `f'.  The hexadecimal digit `f' represents the decimal number 15.)
     `%X' uses the letters `A' through `F' instead of `a' through `f'.

`%'
     This isn't really a format-control letter, but it does have a
     meaning when used after a `%': the sequence `%%' outputs one `%'.
     It does not consume an argument, and it ignores any modifiers.

   When using the integer format-control letters for values that are
outside the range of a C `long' integer, `gawk' will switch to the `%g'
format specifier. Other versions of `awk' may print invalid values, or
do something else entirely (d.c.).


Next: Format Modifiers Prev: Basic Printf Up: Printf
[ Dokumentation lokal installierter Software ]