Re: [SLUG] Command help

From: Eben King (eben1@tampabay.rr.com)
Date: Sun Feb 12 2006 - 15:57:30 EST


On Sun, 12 Feb 2006, Ian Blenke wrote:

> Bob Stia wrote:
>> Hello Sluggers,
>>
>> What is wrong with the following command? Trying to figure out how much to
>> shrink down a movie.m2v Not a bash command?
>>
>> EasyStreet:/backup # factor = (6423971301/ (4600000000. - 232415232 ) ) *
>> 1.04
>> bash: syntax error near unexpected token `('
>> EasyStreet:/backup #
>>
>
> If you have integers (not floats), you can do the following:
>
> #!/bin/bash
> (( factor = 6423971301/ (4600000000 - 232415232 ) ))
> echo $factor

There can't be spaces around the "=" in "foo=bar", I don't think. Unless
that's a different environment.

> There's probably another way to handle floats, but this is what I'd probably
> end up doing:
>
> factor=$( echo 'scale=2; (6423971301/ (4600000000. - 232415232 ) ) * 1.04'
> | bc )
>
> Using bc is a bit of cheating, but it's quick and dirty, and it works.

Yeah, but I'd use dc. Same idea.

> The "scale=2" means that you want two places to the right of the decimal.

What do you want, the scale of a 6.4*10^10^9 byte movie to fit it and
232*10^6 bytes of other stuff to fit them both on a 4.6*10^9 byte DVD?

room=$(( 4600000000 - 232415232 ))
scale=$(( ( room * 100 ) / 6423971301 ))
echo "${scale}%"

Decimals are a PITA in bash.

-- 
-eben    ebQenW1@EtaRmpTabYayU.rIr.OcoPm    home.tampabay.rr.com/hactar

Q: What kind of modem did Jimi Hendrix use? A: A purple Hayes. ----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 18:22:23 EDT