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