I am a beginner in bash script programming. I wrote a small script in Python to calculate the values of a list from an initial value up to the last value increasing with 0.5. The Python script is:
# A script for grid corner calculation.
#The goal of the script is to figure out the longitude values which increase with 0.5
# The first and the last longitude values according to CDO sinfo
L1 = -179.85
L2 = 179.979
# The list of the longitude values
n = []
while (L1 < L2):
L1 = L1 + 0.5
n.append(L1)
print "The longitude values are:", n
print "The number of longitude values:", len(n)
I would like to create a same script by bash shell. I tried the following:
!#/bin/bash
L1=-180
L2=180
field=()
while [ $L1 -lt $L2 ]
do
scale=2
L1=$L1+0.5 | bc
field+=("$L1")
done
echo ${#field[@]}
but it does not work. Could someone inform me what I did wrong? I would appreciate if someone helped me.
she-bangline is wrong, should have been#!/bin/bashL1that is wrong.