often shell scripting can be useful for writing "here documents" or rather
complete scripts suitable for math calculation with R or octave or anything
else... For instance you can do
#!/bin/bash
var_1=$(do something with awk on the file X.dat)
array_1=( $(do something with awk on the file Y.dat ) )
limit=1000
for ((i=0;i<${limit};i++))
cat >my_script <<EOF
....
write here what you want to do with the variables you've just extracted
with the bash tools ${var_1} ${arra_[${i}]}
....
EOF
R (or octave or matlab or my own C program...) < my_script
.....
or directly if you are not interested in conserving a copy of your script
R (or octave or ....) <<EOF
write here what you want to do with the variables you've just extracted
with the bash tools ${var_1} ${arra_[${i}]}
...
...
EOF
HTH
Mariano
2012/2/9 Jason Swails <jason.swails.gmail.com>
> 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
>
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Thu Feb 09 2012 - 13:00:02 PST