I have the following code:
# Get the line of stations_info.txt starting with "${xstation1} " and copy it to file temp.txt
grep "^${xstation1} " stations_info.txt > temp.txt
# Get lat and long of station
nl=0
LEN=0
while [ ${LEN} -lt 10 ]; do
line=
let nl=nl+1
line=$(head -n ${nl} temp.txt)
LEN=$(echo ${#line})
done
echo $line > temp2.txt
lat=`awk '{print $3}' temp2.txt`
long=`awk '{print $4}' temp2.txt`
echo ${lat} ${long} >> ${PROJECT}/sources.txt
rm temp.txt temp2.txt
The idea is to take the line of stations_info.txt which has the station name in the line. I then want to find the line with a length greater than 10. Using this line I need to extract the values from the third and fourth columns. My problem is that the line just extends and isn't reset. How can I get the line to reset, or do the above in another way?
Thanks in advance
---------- Post updated at 01:09 PM ---------- Previous update was at 01:03 PM ----------
I was being silly - have to change head