Background
In Microsoft Windows, Launched Cygwin terminal mode and running a little bash shell script.
But, getting the error “$’\r’: command not found”
The \r is a dead giveaway, as it means there is something amiss with Line Character and Carriage Return.
Fix
To fix:
- Launched Notepad++
- Load the Bash Script File
- Access the menu items “Edit\EOL Conversion\Unix Format”
- Re-save file (File \ Save)
Addendum
Addendum – Thursday July 10th, 2014
Please try the following StackOverflow Q/A postings:
They discuss using dos2unix to accomplish same thing. Â Crediting Roman Hocke and “me_and“.
hey nice post dude…
Excellent! Solved my problem quickly. I posted a link to this on StackOverflow.
Thanks for sharing.
John:
Happy it was a bit of use.
Thanks for the feedback the and the StackOverflow plug.
Daniel
hey even though i tried with the above thing still iam getting Same error
Please try converting the windows file that relies on CRLF to Unix using unix2dos
http://stackoverflow.com/questions/9269706/replace-lf-with-cr-lf-in-text-file-cygwin
You’re specifying the path to unix2dos using a bizarre mix of Windows and Linux file endings.
If you’re calling it from a windows command shell, use this:
unix2dos d:\temp.txt
If you’re calling it from within Cygwin, or a Cygwin shell script or similar, use this:
unix2dos /cygdrive/d/temp.txt
Thanks,
Daniel
[…] https://danieladeniji.wordpress.com/2013/03/07/microsoft-windows-cygwin-error-r-command-not-found/ […]
THANK YOU! This was super helpful.
Jonathan:
You are most welcome family.
Happy Holidays and Safe & Prosperous year ahead.
Daniel
Thank you so much!