From: Gary Williamson on
In a shell script I coded:

printf "padded=%02d:%02d:%02d\n", $hour,$minute,$sec

With the following values:
$hour=0
$minute=7
$sec=26

However when I run the script I get an error:

/usr/local/gary/bin/myscript: line 37: printf: 0,7,26: invalid number
time=00:00:00

Why?

Gary
From: Bill Marcum on
On 2008-06-19, Gary Williamson <garywill(a)usca.edu> wrote:
> In a shell script I coded:
>
> printf "padded=%02d:%02d:%02d\n", $hour,$minute,$sec
>
> With the following values:
> $hour=0
> $minute=7
> $sec=26
>
> However when I run the script I get an error:
>
> /usr/local/gary/bin/myscript: line 37: printf: 0,7,26: invalid number
> time=00:00:00
>
> Why?
>
Use spaces, not commas, between arguments in a shell script.

printf "padded=%02d:%02d:%02d\n" $hour $minute $sec
From: Stephane CHAZELAS on
2008-06-19, 08:23(+02), Bill Marcum:
[...]
> Use spaces, not commas, between arguments in a shell script.
>
> printf "padded=%02d:%02d:%02d\n" $hour $minute $sec

printf "padded=%02d:%02d:%02d\n" "$hour" "$minute" "$sec"

remember that leaving a variable unquoted has a very special
meaning to the shell.

--
St�phane