Re: [SLUG] Command help

From: Kwan Lowe (kwan@digitalhermit.com)
Date: Sun Feb 12 2006 - 07:39:29 EST


> 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 #

   http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-10.html#ss10.2

   From the above:

10.2 Arithmetic evaluation

On the command line (or a shell) try this:

echo 1 + 1

If you expected to see '2' you'll be disappointed. What if you want BASH to evaluate
some numbers you have? The solution is this:

echo $((1+1))

This will produce a more 'logical' output. This is to evaluate an arithmetic
expression. You can achieve this also like this:

echo $[1+1]

If you need to use fractions, or more math or you just want it, you can use bc to
evaluate arithmetic expressions.

if i ran "echo $[3/4]" at the command prompt, it would return 0 because bash only
uses integers when answering. If you ran "echo 3/4|bc -l", it would properly return
0.75.

-- 
* The Digital Hermit   http://www.digitalhermit.com
* Unix and Linux Solutions   kwan@digitalhermit.com
-----------------------------------------------------------------------
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:20:49 EDT