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: Barry Margolin on
In article <4859ee98$0$6603$9b4e6d93(a)newsspool2.arcor-online.net>,
garywill(a)usca.edu (Gary Williamson) 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?
>
> Gary

This is shell, not C; arguments to commands are delimited with
whitespace, not commas:

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

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
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