[opensuse] Need reference for 'printf -v var "format" value` (info coreutils/printf invocation - is silent)
All, I need a reference citation for the use of `printf -v` that writes the formatted output for a value to a variable. The use is: printf -v varname "format specifier" value example: $ printf -v f "0x%02x" 13 $ echo $f 0x0d I know how to use it, I just can't find a reference that tells me I can use it like that. I've checked the man pages and info coreutils/printf invocation, but I can't find a reference to the `-v` option anywhere. What say the gurus? -- David C. Rankin, J.D.,P.E. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
David C. Rankin wrote:
All,
I need a reference citation for the use of `printf -v` that writes the formatted output for a value to a variable. The use is:
printf -v varname "format specifier" value
example:
$ printf -v f "0x%02x" 13 $ echo $f 0x0d
I know how to use it, I just can't find a reference that tells me I can use it like that. I've checked the man pages and info coreutils/printf invocation, but I can't find a reference to the `-v` option anywhere.
Hardly a reference, but it's shown when you enter "printf --help" : per@io64:~> printf --help bash: printf: --: invalid option printf: usage: printf [-v var] format [arguments] "printf -v var" is new to me, I would have used $() instead: f=$(printf "0x%02x" 13) -- Per Jessen, Zürich (21.4°C) http://www.hostsuisse.com/ - dedicated server rental in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 07/01/2015 12:57 AM, David C. Rankin wrote:
I know how to use it, I just can't find a reference that tells me I can use it like that. I've checked the man pages and info coreutils/printf invocation, but I can't find a reference to the `-v` option anywhere.
What say the gurus?
It is not the printf from coreutils, it is the bash builtin. So 'man bashbuiltins' gives you everything you need to know. -- David C. Rankin, J.D.,P.E. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 7/1/2015 1:05 AM, David C. Rankin wrote:
On 07/01/2015 12:57 AM, David C. Rankin wrote:
I know how to use it, I just can't find a reference that tells me I can use it like that. I've checked the man pages and info coreutils/printf invocation, but I can't find a reference to the `-v` option anywhere.
What say the gurus?
It is not the printf from coreutils, it is the bash builtin. So 'man bashbuiltins' gives you everything you need to know.
It's on the bash man page as: 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 output. --- Is that what you mean? -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 07/01/2015 08:13 AM, Linda Walsh wrote:
It's on the bash man page as: 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 output.
--- Is that what you mean?
Yes, Sorry, I was suffering from a brief 'cranial rectal inversion'... -- David C. Rankin, J.D.,P.E. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (3)
-
David C. Rankin
-
Linda Walsh
-
Per Jessen