LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-02-2009, 04:59 AM   #1
sima h
LQ Newbie
 
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
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
 
Old 08-02-2009, 10:56 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2017 CentOS6.9 CentOS7.4 + 50+ other Linux OS, for test only.
Posts: 16,755

Rep: Reputation: 3329Reputation: 3329Reputation: 3329Reputation: 3329Reputation: 3329Reputation: 3329Reputation: 3329Reputation: 3329Reputation: 3329Reputation: 3329Reputation: 3329
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
.....

Last edited by knudfl; 08-02-2009 at 11:16 AM.
 
Old 08-02-2009, 08:19 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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
 
  


Reply

Tags
linux


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax error: unexpected end of file ygdrazil Linux - Newbie 3 07-23-2009 06:00 AM
Bash script -----------syntax error: unexpected end of file ArthurHuang Programming 2 05-01-2009 11:29 AM
Sntax error : unexpected end of file while executing shell script priyankarathi Linux - Newbie 5 04-21-2009 02:33 AM
Bash script - syntax error: unexpected end of file Mr Pink Programming 7 12-19-2008 07:31 AM
'unexpected end of file' error saru06 Programming 2 08-09-2007 02:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration