Re: Bash printf oddity; octal?

2014-05-04 Thread Asif Iqbal
On Sun, May 4, 2014 at 4:32 PM, ~Stack~ i.am.st...@gmail.com wrote:

 Greetings,

 I know this isn't explicitly a Debian problem, but I have seen many
 really smart Bash programmers on this list so I figured this was a good
 place to ask. :-)

 $ bash --version
 GNU bash, version 4.2.37(1)-release (x86_64-pc-linux-gnu
 $ cat /etc/debian_version
 7.5

 I have a Bash script I am working on where I am getting (supposedly) a
 two-digit number from the user. I handle all the logic to ensure I am
 getting two digits and not 2, letters, characters, ect in a different
 function. By the time I get to this code in my script, I am assuming it
 is a one or two digit number. Because I need a two digit number I am
 assuming that my user may have just input a single digit for the first
 nine numbers without a leading zero. I am doing this in my code like:

 verifiednum=`printf %02d $uservar`

 This works really well when they enter only a single digit or 01-07.
 However, on 08 or 09, this fails.

 $ cat test.sh
 #!/bin/bash -
 printf %02d 07 #This Works.
 echo 
 printf %02d 8  #This Works.
 echo 
 printf %02d 08 #This doesn't.
 echo 
 printf %02d 9  #This Works.
 echo 
 printf %02d 09 #This doesn't.
 echo 

 $ ./test.sh
 07
 08
 ./test.sh: line 6: printf: 08: invalid octal number
 00
 09
 ./test.sh: line 10: printf: 09: invalid octal number
 00

 I almost want to think that this is a bug, but because it seems to be
 thinking it is an octal number (which technically it is I suppose :). I
 am guessing that it just doesn't like what I am doing with printf but I
 am a bit baffled as to why it only croaks on 08 and 09.

 1) Does anyone know what is wrong here?


leading zero is interpreted as octal. You need to prepend the number
with 10# to convert it to decimal first



 2) Is there a better way of solving this issue?


so try this instead  printf %02d $(( 10#08 ))

Thanks!
 ~Stack~




-- 
Asif Iqbal
PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?


Re: Bash printf oddity; octal?

2014-05-04 Thread Asif Iqbal
On Sun, May 4, 2014 at 4:54 PM, ~Stack~ i.am.st...@gmail.com wrote:

 That makes sense. But why does it only fail on 08 and 09? Shouldn't it
 also fail on 01-06?



Isn't that obvious? Unless in your world, octal 6 is different than decimal
6 :-)

-- 
Asif Iqbal
PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?


Re: video compression?

2014-02-18 Thread Asif Iqbal
On Mon, Feb 17, 2014 at 8:23 AM, Thomas H. George li...@tomgeorge.infowrote:

 Is there a best debian program to compress avi videos enough to send
 them by email?


why not upload it to your youtube account, make it unlisted and email the
link(s)?

If it is too big may be chop it in parts and then upload each part to
youtube.



 I have found ffmpeg and avidemux and am trying to learn to use them but
 have not had much success so far.

 Tom


 --
 To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
 with a subject of unsubscribe. Trouble? Contact
 listmas...@lists.debian.org
 Archive: http://lists.debian.org/20140217132326.ga24...@tomgeorge.info




-- 
Asif Iqbal
PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?