LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   syntax error near unexpected token `fi' (https://www.linuxquestions.org/questions/programming-9/syntax-error-near-unexpected-token-%60fi-218062/)

Warmduvet 08-16-2004 04:00 PM

Thanks for all the replies and suggestions.

WD

bulliver 08-16-2004 06:50 PM

The advanced bash scripting guide is a good online resource:
http://www.tldp.org/LDP/abs/html/index.html

If you need something a little more basic try the Bash Guide for Beginners:
http://www.tldp.org/LDP/Bash-Beginne...tml/index.html

jlliagre 08-16-2004 07:19 PM

JLM-TOC,

2) the history exansion problem you describe is real, but is only concerning interactive shells. Shell scripts shouldn't be affected.

jons 02-08-2007 05:20 AM

[bash] new to bash, having problems debugging.
 
oops posted in wrong place.

TheDexxter24 06-01-2013 05:13 AM

Quote:

sh, ksh, and bash don't allow unquoted spaces in shell-variable assignments.
So:
FILES=/usr/local/rpm /etc/samba /etc/httpd
will set FILES to "/usr/local/rpm" and then try to execute:
/etc/samba /etc/httpd
You can also put some '\' before the space to say "don't take care about what's following"
So you'll have:
FILES=/usr/local/rpm\ /etc/samba /etc/httpd
:)
Sorry for my bad english :S

David the H. 06-02-2013 06:32 AM

Just to warn everyone, this is 9 year old necro-thread.

In the future, please consider whether what you want to add is important enough to justify re-opening a long-dead thread. Thanks.

While I'm here, I'm going to add my own comment though, and say that lists of filenames should not be stored in a single variable anyway. Always use arrays when you have multiple related strings to operate on.

Code:

files=( /usr/local/rpm /etc/samba /etc/httpd  )
printf 'This is file: %s\n' "${files[@]}"


dy20082250 10-08-2013 10:28 AM

I also have a similar question about 'fi'
 
INSTDIR=/home/wdy/Download
if [ -d $(INSTDIR) ];\
then\
cp myapp $(INSTDIR);\
chmod a+x $(INSTDIR)/myapp;\
chmod og-w $(INSTDIR)/myapp;\
echo "Installed in $(INSTDIR)";\
else\
echo "sorry,$(INSTDIR) does not exist";\
fi



run it and the error:syntax error near unexpected token 'fi'
but why? ican not find the reason.


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