Bash syntax error: unexpected end of file
Here’s the code:
- after running sh file.sh:
- syntax error: unexpected end of file
- file.sh is with CRLF line terminators.
then the problem will be fixed.
- You can install dos2unix in ubuntu with this:
- Terminate bodies of single-line functions with semicolon
I.e. this innocent-looking snippet will cause the same error:
[ad type=”banner”]- To make the dumb parser:
- We needed on cygwin :-
in .bash_profile . This way we didn’t need to run unix2dos
- Make sure the name of the directory in which the .sh file is present does not have a space character.
- e.g: Say if it is in a folder called ‘New Folder’, you’re bound to come across the error that you’ve cited. Instead just name it as ‘New_Folder’.
Correct solution and easy way
perfect one..was helpful