I am fairly new to bash and am not sure how to resolve this:
I have a series of geographical long/lat points eg. 50/-30 listed on separate lines in a file called junk2. I have input these into an array and am then using that array in a for loop. Towards the end of the loop I create a file called profile$NUMBER. For each loop I wish to name the profile "profile1" for the first loop, then "profile2" for the second loop, ie. have $NUMBER increase by 1 each time, but how can I do this?
I have the following code so far:
# !/bin/bash/
array=()
# Read the file in parameter and fill the array named "array"
getArray() {
i=0
while read line # Read a line
do
array=$line # Put it into the array
i=$(($i + 1))
done < $1
}
getArray "junk2"
# Print the file (print each element of the array)
getArray "junk2"
for e in "${array[@]}"
do
project -C$e -A145 -G0.01k -L-2500/2500 -Q > junk3
cat junk3 | grdtrack -GSWIR_bath.grd > junk4
cat junk4 | grdtrack -GSWIR_grav.grd > junk5
cat junk5 | grdtrack -Gnonairyisotopo2.grd > junk6
cat junk6 | grdtrack -Gmarion_mask.grd >profile$NUMBER.xydzgim
echo "Ridge location $e done"
done
Many thanks
Lily