|
Prev: apt-get GPG key error message
Next: Achat Cigarette - Mersi avoir visité en ligne notre magasin de cigarettes Notre bureau de tabac à reductions importantes vous offert les meilleurs choix des cigarettes de marques connues dans le monde entier avec un service de livraison de la premièr
From: Gary Williamson on 19 Jun 2008 01:28 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 19 Jun 2008 01:36 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 19 Jun 2008 02:23 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 19 Jun 2008 03:04 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
|
Pages: 1 Prev: apt-get GPG key error message Next: Achat Cigarette - Mersi avoir visité en ligne notre magasin de cigarettes Notre bureau de tabac à reductions importantes vous offert les meilleurs choix des cigarettes de marques connues dans le monde entier avec un service de livraison de la premièr |