Re: [SLUG] Command help

From: Ian Blenke (icblenke@nks.net)
Date: Sun Feb 12 2006 - 15:23:42 EST


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'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.

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

-- 
- Ian C. Blenke <icblenke@nks.net>


----------------------------------------------------------------------- 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:21:51 EDT