Computing.Net > Forums > Linux > Bash Script Unexpected end of file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Bash Script Unexpected end of file

Reply to Message Icon

Name: littlemissknit
Date: March 10, 2005 at 18:29:53 Pacific
OS: Red Hat Linux
CPU/Ram: IBM clone
Comment:

Thanks for the great tip, its worked great!
now i'm trying to fix an end of file problem. I've programmed this file to delete all zero length files and i keep getting an end of file error
#!/bin/bash

if [$1 == -f]
then
find $2 -empty -print -exec rm -f {}\
else
find $1 -empty -ok rm -f {}\
fi


i've tried adding "done" "exit" and "exit 0"
there is definetly something I'm missing here!

Littlemissknit



Sponsored Link
Ads by Google

Response Number 1
Name: Xavier HECQUET
Date: March 11, 2005 at 04:00:31 Pacific
Reply:

Don't forget the "point-comma" (excuse-me, I'm french, don't know the real name) : ";"

I think some spaces are also missing.

I think this should be:

if [$1 == -f]
then
find $2 -empty -print -exec rm -f {} \;
else
find $1 -empty -ok rm -f {} \;
fi

Regards

Xavier


0

Response Number 2
Name: littlemissknit
Date: March 11, 2005 at 06:34:28 Pacific
Reply:

i entered what you said and it said that for the "if [$1 == -f]" that i'm missing a ']' but i closed the line like you did in the file.
it also says i'm missing an argument to "-ok'


0

Response Number 3
Name: kk7av
Date: March 24, 2005 at 23:40:02 Pacific
Reply:

Try adding quotes. Ex:

if [ "$1" = "-f" ]

All of the Bash shell scripts I've written required the arguments to be quoted. Also in Bash, I think you can use a single equals sign for evaluation. See the following for some examples:

http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-6.html#ss6.3

Good luck!


Rob Pectol
http://rob.pectol.com/


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Bash Script Unexpected end of file

syntax error: unexpected end of file www.computing.net/answers/linux/syntax-error-unexpected-end-of-file/9663.html

Amsn unexpected end of file www.computing.net/answers/linux/amsn-unexpected-end-of-file/23770.html

syntax error: unexpected end of fil www.computing.net/answers/linux/syntax-error-unexpected-end-of-fil/30155.html