Search code examples
bashunixcygwinsyntax-error

error while trying to run a script in cygwin


unexpected end of file. now I did a search on the error and I understand that my script file (that was created in windows) has wrong endings. I also read that I can use dos2unix command on the file to fix this. however, I've tried that and cygwin tells me:

-bash: dos2unix: command not found

other than cygwin I work on a remote unix terminal, on which my script runs fine and there is even a dos2unix command. I've used it on the script file, and tried to use the converted file in cygwin with the same unexpected end of file error. so what are my options?


Solution

  • You can install dos2unix from the cygwin setup utility

    But, this should work too:

    sed -i 's/\r$//' file
    

    However, "unexpected end of file" often means you have an open quote (or brace or parenthesis) with no close quote (or brace or parenthesis)