./chkf: line 30: syntax error near unexpected token `elif'
'/chkf: line 30: `elif [ -f "$object" ] ; then
if [ -d "$object" ] ; then
message="$message a directory"
elif [ -f "$object" ] ; then
message="$message a regular file."
else
message="$message not a known file type"
fi
Also this,
./chkf: line 38: syntax error near unexpected token `else'
'/chkf: line 38: `else
if [ -w "$object" ] ; then
write="writeable"
else
write="not writeable"
fi
What is wrong with this? It seems to be correct. I tried so many variations and cannot figure out what is wrong. Is there some kind of invisible character? If so, is there a command to strip it?
Edit: When I add #!/bin/bash
at the top, I get the following error:
interpreter "/bin/bash" not found
file link resolves to "/usr/bin/bash"
-bash: ./chkf: /bin/bash^M: bad interpreter: No such file or directory
It's your line endings. Transferring it from Windows has left the
CR/LF
line endings on.When I create a script then manually add the
CR
characters, I get exactly the same error:You can fix it by removing the CR character from CR/LF line endings.
\015
octal representation as listed in ASCIII got below error in my mail when i set up cron for magento.
I found solution for that is i remove newline space from my cron1.php file. and its work.
(source)
Now that you've added the additional error message, I have a thought: the
^M
is \r, which is the Mac OS X line ending or part of the Windows line ending - Linux uses \n only as EOL. If you edit invim
, you should be able to see the^M
if it's not right through the file.Two ways to resolve this
1) Using Sed:-
Syntax
2) Using dos2unix command
Syntax
it looks like you've got the "dos problem", embedded control-M's in your file. fix it with sed: