Math in general is tricky (to say the least) in bash. You certainly don't
want to do any kind of heavy-duty maths in bash, but for simple stuff the
"bc" program is a good solution (that's how I do all my bash-maths).
Something like this:
# increment j:
j=`echo "$j + 1" | bc`
# add 3 and 2
k=`echo "3+2" | bc`
echo $k
HTH,
Jason
On Thu, Feb 9, 2012 at 2:26 PM, shenna shearin <smsheari.gmail.com> wrote:
> Hello:
>
> I am learning how to write scripts using Linux. I want to know how to
> create a script to add two integers. Thanks.
> --
> Shenna Shearin
> Ph.D candidate
> Department of Computational Science & Engineering,
> North Carolina A & T State University
> Greensboro, NC 27411
> _______________________________________________
> AMBER mailing list
> AMBER.ambermd.org
> http://lists.ambermd.org/mailman/listinfo/amber
>
--
Jason M. Swails
Quantum Theory Project,
University of Florida
Ph.D. Candidate
352-392-4032
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Thu Feb 09 2012 - 12:30:03 PST