‘bash\r’: No such file or directory. Or, editing unix files on a Windows machine

'bash\r': No such file or directory

What does that mean, you ask yourself? It usually means you are editing *nix script files on a windows system, and then running the files on a *nix machine. For instance in docker, or a VM.

Your GUI solution is to use a text editor that allows you to save with unix line endings. `Notepad++` calls it, very reasonably, `'EOL conversion'`. Sublime text calls it `View->Line Endings`.

Your commandline solution in a bash shell on macos is sed -i.bak $'s/\r//' * and on linux the same but you don't need the ansi-C quoting: sed -i.bak 's/\r//' *
A further complication if you are using git is that it keeps getting reset back to windows. You could fix this with `git config core.autocrlf false` but that may have other consequences which you don't want to bother with.

‘bash\r’: No such file or di…

by Chris F Carroll read it in 1 min
0