LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   yntax error: unexpected end of file (https://www.linuxquestions.org/questions/linux-newbie-8/yntax-error-unexpected-end-of-file-744478/)

sima h 08-02-2009 03:59 AM

yntax error: unexpected end of file
 
Hi Dears

I write a linux script for apply an programm to 1456 files
there is follow:

counter=1
var=1456
while [ $counter -le $var ]; do
asd=$(head list.txt -n $counter | tail -n 1)
echo "$counter = $asd "
ls -l $ias >> asd.txt
ls -l $as > ./results/result$counter.txt
./read_wrf_nc -EditData SNOW $as > ./results/result$counter.txt
echo " yes"
let counter++
done
echo "-------------------------"
echo " done all "

but when I run it
give this error:
./script.txt: line 22: syntax error: unexpected end of file

The line 22 is an emty line in end of script

Please help me

Thanks

Sima

knudfl 08-02-2009 09:56 AM

Code:

    1        counter=1
    2        var=1456
    3        while [ $counter -le $var ]; do
    4        asd=$(head list.txt -n $counter | tail -n 1)
    5        echo "$counter = $asd "
    6        ls -l $ias >> asd.txt
    7        ls -l $as > ./results/result$counter.txt
    8        ./read_wrf_nc -EditData SNOW $as > ./results/result$counter.txt
    9        echo " yes"
    10        let counter++
    11        done
    12        echo "-------------------------"
    13        echo " done all "

'line 22' ?
Anyway, the script works fine, except for the commands
made by the executable called in line 8, which I of course
can't replicate, have no WRF installed.
May be an error in " read_wrf_nc " ?

.....
'ls test-script-directory'
asd.txt list.txt read_wrf_nc* results/ script.txt
.....

chrism01 08-02-2009 07:19 PM

These 2 vars are not assigned before use

$ias
$as

Also, I'd write

./results/result$counter.txt

as

./results/result${counter}.txt

to be on the safe side


All times are GMT -5. The time now is 08:58 AM.