-   Linux - Newbie (
-   -   Error in script (

nawuza 07-27-2008 09:59 PM

Error in script
hello..i am doing a script for checking a file/folder if it exist tin a directory.

the script is in root directory and it looks like this

if [ -f /root/ ]; then
    echo "file found"
    echo "file not found"

i got two error:
unexpexted EOF while looking matching
syntax error: unexpected end of file

please help.

crabboy 07-27-2008 11:02 PM

Script looks fine, what else is in that file?

Mr. C. 07-27-2008 11:50 PM

You are probably editing the file with an editor that doesn't set the correct line endings. Which editor?

Save your files using Unix style line endings.

You can convert the file with dos2unix, or in vim:

vim file
:set ff=unix

chrism01 07-28-2008 03:30 AM

Even quicker version of




Mr. C. 07-28-2008 03:35 AM

I'm a Shift ZZ guy, but wanted to reinforce the : command twice in a row, so it wouldn't be missed.

sir_com 07-28-2008 07:16 AM

Hi nawuza,

The script is absolutely correct and even I have tested in my works. I suggest that ... if you have copied this from some pdf or document then please copy it again using vi/vim/emacs editor.

As suggested you can also run the dos2unix utility/command like "dos2unix <script-name>" and run the script again. This may solve your problem.

In addition to this you may also try quoting the expression like

-f "/root/"


Mr. C. 07-28-2008 11:49 AM


Originally Posted by sir_com (Post 3228599)
In addition to this you may also try quoting the expression like

-f "/root/"

This makes no difference. There is nothing in the string "/root/" that needs protecting from the shell.

nawuza 07-28-2008 08:32 PM

i edit the script using vi.i will try.

All times are GMT -5. The time now is 10:24 AM.