December 1999
Beginner
528 pages
11h 10m
English
Format:
printf format arguments
This command prints formatted text to the standard output, and is similar to awk ’s printf function.
Format:
Format can contain three different types of items; we will only look at formatting. The sequence to format is:
%[- +]m.nx
where the hyphen will left-justify a field. Generally speaking the m is used to represent the length of a field and n is the maximum length of the field.
The % sign is preceded with any of the following to format characters:
| s | string |
| c | character |
| d | decimal |
| x | hexadecimal number |
| o | octal number |
Printf by itself does not generate a new line; you have to use the escape sequence for that. Here is a list of the most common escape sequences.
| \a | sound the bell |
| \b | backspace |
| \r | carriage ... |
Read now
Unlock full access