[ruby-list:50132] Re: sprintf のフォーマット
From:
"TAKANO `takano32' Mitsuhiro" <tak@...32.tk>
Date:
2015-05-04 06:37:06 UTC
List:
ruby-list #50132
man bash =E3=81=A8 info =E6=8E=A2=E3=81=97=E3=81=A6=E3=81=BF=E3=81=9F=E3=81=
=BE=E3=81=97=E3=81=9F=E3=81=8C=E3=80=81 %(...)T =E4=BB=A5=E5=A4=96=E3=81=AF=
=E3=81=BE=E3=81=A0=E7=94=A8=E9=80=94=E3=81=AA=E3=81=84=E3=81=BF=E3=81=9F=E3=
=81=84=E3=81=A7=E3=81=99=E3=80=82
```
printf [-v var] format [arguments]
Write the formatted arguments to the standard output
under the control of the format. The -v option causes the output to
be assigned to
the variable var rather than being printed to the standard ou=
tput.
The format is a character string which contains three
types of objects: plain characters, 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 print-
ing 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 argument (except that \c terminates
output, backslashes in
\', \", and \? are not removed, and octal escapes
beginning with \0 may contain up to four digits).
%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.
```
2015=E5=B9=B45=E6=9C=884=E6=97=A5 14:01 Nobuyoshi Nakada <nobu@ruby-lang.or=
g>:
>
>
> 2015=E5=B9=B45=E6=9C=884=E6=97=A5=E6=9C=88=E6=9B=9C=E6=97=A5=E3=80=81Tana=
ka Akira<akr@fsij.org>=E3=81=95=E3=82=93=E3=81=AF=E6=9B=B8=E3=81=8D=E3=81=
=BE=E3=81=97=E3=81=9F:
>>
>> bash =E3=81=AE printf =E3=81=A7=E3=80=81%(DATEFMT)T =E3=81=A8=E3=81=84=
=E3=81=86=E4=BE=8B=E3=81=AF=E3=81=82=E3=82=8B=E3=82=88=E3=81=86=E3=81=A7=E3=
=81=99=E3=80=82
>>
>> $ printf '%(%F %T %z)T\n' 946652400
>> 2000-01-01 00:00:00 +0900
>
>
> =E3=81=AA=E3=82=8B=E3=81=BB=E3=81=A9=E3=80=82=E3=81=A8=E3=81=93=E3=82=8D=
=E3=81=A7%(...)=E3=81=AFT=E4=BB=A5=E5=A4=96=E3=81=A7=E3=82=82=E4=BD=BF=E3=
=81=88=E3=82=8B=E3=81=AE=E3=81=A7=E3=81=97=E3=82=87=E3=81=86=E3=81=8B=E3=80=
=82