‘\r’: command not found – .bashrc / .bash_profile [duplicate]

When all else fails in Cygwin…

Try running the dos2unix command on the file in question.

It might help when you see error messages like this:

-bash: '\r': command not found

Windows style newline characters can cause issues in Cygwin.

The dos2unix command modifies newline characters so they are Unix / Cygwin compatible.

CAUTION: the dos2unix command modifies files in place, so take precaution if necessary.

If you need to keep the original file, you should back it up first.

Note for Mac users: The dos2unix command does not exist on Mac OS X.

Check out this answer for a variety of solutions using different tools.

There is also a unix2dos command that does the reverse:

It modifies Unix newline characters so they’re compatible with Windows tools.

If you open a file with Notepad and all the lines run together, try unix2dos filename.

Leave a Comment