printf(1) printf(1)
名前
printf - データを整形して表示する
書式
printf format [argument...]
printf [--help] [--version]
説明
printf は文字列 format を表示する。その際 ‘%’ は書式指定子として、また
‘\’ はエスケープ文字として解釈される。解釈のしかたは C の printf(3) 関
数 と同じである。引き数 format は与えられた argument すべてをコンバート
するのに必要な回数分再利用される。
printf は表示する文字の番号を指定するために、以下のエスケープを認識する
。
\ooo 8 進数 (‘ooo’ の部分は 1 桁から 3 桁まで)
\xhh 16 進数 (‘hh’ の部分は 1 桁から 2 桁まで)
\uNNNN Unicode 16 ビットコード
\UNNNNNNNN
Unicode 32 ビットコード
Unicode は 環境変数 LC_CTYPE に基づいて表示され、iconv を必要とする。
printf には ‘\c’ というエスケープが追加されており、表示をその位置で停止
さ せる。また ‘%b’ という書式指定子が追加されている。これは引き数で指定
された文字列中の ‘\’ を format 内部で指定された ‘\’ と同じように取り 扱
う。
オプション
GNU printf が引き数 1 つだけで起動された場合には、以下のオプションが認
識される:
--help 標準出力に使用方法のメッセージを出力して正常終了する。
--version
標準出力にバージョン情報を出力して正常終了する。
注意
プログラムのバグについては bug-sh-utils@gnu.org に報告してください。 ペ
ージの更新は Ragnar Hojland Espinosa
PRINTF(1) User Commands PRINTF(1)
NAME
printf - format and print data
SYNOPSIS
printf FORMAT [ARGUMENT]...
printf OPTION
DESCRIPTION
Print ARGUMENT(s) according to FORMAT, or execute according to OPTION:
--help display this help and exit
--version
output version information and exit
FORMAT controls the output as in C printf. Interpreted sequences are:
\" double quote
\\ backslash
\a alert (BEL)
\b backspace
\c produce no further output
\e escape
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\NNN byte with octal value NNN (1 to 3 digits)
\xHH byte with hexadecimal value HH (1 to 2 digits)
\uHHHH Unicode (ISO/IEC 10646) character with hex value HHHH (4 digits)
\UHHHHHHHH
Unicode character with hex value HHHHHHHH (8 digits)
%% a single %
%b ARGUMENT as a string with ‘\’ escapes interpreted, except that
octal escapes are of the form \0 or \0NNN
and all C format specifications ending with one of diouxXfeEgGcs, with
ARGUMENTs converted to proper type first. Variable widths are handled.
NOTE: your shell may have its own version of printf, which usually
supersedes the version described here. Please refer to your shell’s
documentation for details about the options it supports.
AUTHOR
Written by David MacKenzie.
REPORTING BUGS
Report printf bugs to bug-coreutils@gnu.org
GNU coreutils home page:
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa