作者: tc1989tc 时间: 2015-09-17 09:53
man bash
printf [-v var] format [arguments]
Write the formatted arguments to the standard output under the control of the
format. The format is a character string which contains three types of
objects: plain characters, which are simply copied to standard output, char-
acter escape sequences, which are converted and copied to the standard out-
put, and format specifications, each of which causes printing of the next
successive argument. In addition to the standard printf(1) formats, %b
causes printf to expand backslash escape sequences in the corresponding argu-
ment (except that \c terminates output, backslashes in \', \", and \? are not
removed, and octal escapes beginning with \0 may contain up to four digits),
and %q causes printf to output the corresponding argument in a format that
can be reused as shell input.
The -v option causes the output to be assigned to the variable var rather
than being printed to the standard output.
The format is reused as necessary to consume all of the arguments. If the
format requires more arguments than are supplied, the extra format specifica-
tions behave as if a zero value or null string, as appropriate, had been sup-
plied. The return value is zero on success, non-zero on failure.作者: sunzhiguolu 时间: 2015-09-17 10:48 本帖最后由 sunzhiguolu 于 2015-09-17 10:49 编辑
The -v option causes the output to be assigned to the variable var rather
than being printed to the standard output.作者: sunzhiguolu 时间: 2015-09-17 13:39 回复 8# tc1989tc
能不能给个具体的例子?
就是针对我的这个问题, 这个选项如何使用?