Content
Data
License: GNU GPLv3 +
Version number: GNU Bash 5
Developer / owner: Free Software Foundation Inc.
Short description:
The manual page and help for the printf built-in Bash command. The printf command prints text formatted based on the parameters received to standard output.
Man page output
man bash
[...]
printf [-v var] format [arguments]
Write the formatted arguments to the standard output under the control of the for-
mat. The -v option causes the output to be assigned to the variable var rather
than being printed to the standard output.
The format is a character string which contains three types of objects: plain char-
acters, which are simply copied to standard output, character escape sequences,
which are converted and copied to the standard output, and format specifications,
each of which causes printing of the next successive argument. In addition to the
standard printf(1) format specifications, printf interprets the following exten-
sions:
%b causes printf to expand backslash escape sequences in the corresponding ar-
gument in the same way as echo -e.
%q causes printf to output the corresponding argument in a format that can be
reused as shell input.
%(datefmt)T
causes printf to output the date-time string resulting from using datefmt as
a format string for strftime(3). The corresponding argument is an integer
representing the number of seconds since the epoch. Two special argument
values may be used: -1 represents the current time, and -2 represents the
time the shell was invoked. If no argument is specified, conversion behaves
as if -1 had been given. This is an exception to the usual printf behavior.
Arguments to non-string format specifiers are treated as C constants, except that a
leading plus or minus sign is allowed, and if the leading character is a single or
double quote, the value is the ASCII value of the following character.
The format is reused as necessary to consume all of the arguments. If the format
requires more arguments than are supplied, the extra format specifications behave
as if a zero value or null string, as appropriate, had been supplied. The return
value is zero on success, non-zero on failure.
[...]
Help output
printf --help
printf: printf [-v változó] formátum [argumentumok]
FORMÁTUM alapján az ARGUMENTUMOK kiírása.
Kapcsolók:
-v változó a kimenet VÁLTOZÓ nevű változóba írása a szabványos
kimenet helyett
A FORMÁTUM egy karakterlánc, amely három fajta primitívből áll:
egyszerű karakterek, amelyeket a parancs a kimenetre másol; escape-
karaktersorozatok, amelyeket átalakítva másol a kimenetre; valamint
formátumjelzők, amelyek rendre a következő argumentum kiírását
szabályozzák.
A printf(1) által használt szokásos jelzőkön túl a
következőket ismeri a printf parancs:
%b karakterlánc kiírása az escape-szekvenciák értelmezése után
%q argumentum idézőjelezése olyan módon, hogy parancsértelmező
bemeneteként használható legyen
%(fmt)T dátum-idő karakterlánc kiírása az FMT mint strftime(3)
formátum-karakterlánc használatával
A formátum szükség szerint újrafelhasználásra kerül az összes argumentum
elfogyasztásához. Ha kevesebb argumentum van a formátumnak szükségesnél,
az extra formátumjelzők úgy viselkednek, mintha nulla érték vagy null
karakterlánc lett volna megadva.
Kilépési kód:
Sikerrel tér vissza, kivéve ha hibás kapcsolókat kap, vagy az írás/
értékadás hibával járt.
Related Content
- 41 views