You become crazy because after hours of trials and errors, your brand new (and probably first) shell script still complains about “syntax error: unexpected “fi” (expecting “then”)”, “syntax error: unexpected “fi” (expecting “then”)” or “syntax error: unexpected word (expecting “in”)”, … The problem is probably with the EOL.
Click to Read More
The problem could indeed be that you are editing your script with a Windows Text Editor… In such a case, you have to convert the Windows EOL (End Of Line character) into the Linux equivalent.
Edit your script with Notepad++ and use the menu “Edit” > “EOL Conversion” > “Unix/OSX Format”. Then save your script and try again…
You may also have to use the ANSI encoding with the menu “Encoding” > “Convert to ANSI”
Leave a Reply