LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 03: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, 09:56 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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 10:16 AM.
 
Old 08-02-2009, 07:19 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

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



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 05:00 AM
Bash script -----------syntax error: unexpected end of file ArthurHuang Programming 2 05-01-2009 10:29 AM
Sntax error : unexpected end of file while executing shell script priyankarathi Linux - Newbie 5 04-21-2009 01:33 AM
Bash script - syntax error: unexpected end of file Mr Pink Programming 7 12-19-2008 06:31 AM
'unexpected end of file' error saru06 Programming 2 08-09-2007 01:02 AM

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

All times are GMT -5. The time now is 09:33 AM.

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
Open Source Consulting | Domain Registration