Thank you


:-)~MIKE~(-:

On Mon, Mar 2, 2015 at 7:27 PM, Bryan O'Neal <Bryan.ONeal@theonealandassociates.com> wrote:
You can also use let, which may make more sense 
     let "myVar=$myVar+1"
 As for floating point you need something like bc to handle that
     myVar=5.4
     myOtherVar=3.1
     myVar=$(echo "scale=2; ($myVar + 3.14) / $myOtherVar" | bc)
     echo $myVar
If ran the above would print 2.75

On Mon, Mar 2, 2015 at 7:15 PM, der.hans <PLUGd@lufthans.com> wrote:
Am 02. Mär, 2015 schwätzte Michael Havens so:

moin moin Mike,

see the Arithmetic Expansion portion of the bash man page for details.

$((expression))

That says to evaluate the expression and substitute the result. Remember
that the shell only does interger math, no decimals.

:) ~$ echo $(( 4 / 2 ))
2
:) ~$ echo $(( 4 / 3 ))
1
:) ~$ echo $(( 4 * 3 ))
12
:) ~$

Note that you don't need to escape the * when using arithmetic expansion
because the $(( )) is already quoting.

ciao,

der.hans


just starting with this so please, bear with me....

Anyways I am looking at this beginner's script:

  #! /bin/bash
  myvar=0
  while [ $myvar -ne 20 ]
  do
          echo $myvar
          myvar=$(( $myvar + 1 ))
  done

Now my mind can wrap itself around everything in this script except for tis
line:

  myvar=$(( $myvar + 1 ))

Where my difficulty arises is why the '$' before the '(('?
(it was geast fun running that script with a minus sign instead!)
:-)~MIKE~(-:


--
http://www.LuftHans.com/        http://www.PhxLinux.org/
#  "The first requisite of a good citizen in this republic of ours is that
#  he should be able and willing to pull his weight."  -- Theodore Roosevelt

---------------------------------------------------
PLUG-discuss mailing list - PLUG-discuss@lists.phxlinux.org
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss


---------------------------------------------------
PLUG-discuss mailing list - PLUG-discuss@lists.phxlinux.org
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss