‘bash\r’: No such file or directory
Computer Notes > Linux > ‘bash\r’: No such file or directory
Overview=
This is a classic "invisible" headache. It usually happens because of a disagreement between Windows and Unix-based systems (like Linux or macOS) on how a line of text should end.
The Culprit: Line Endings
In the world of text files, there are two main ways to signal the end of a line:
LF (Line Feed): Used by Linux/macOS. Represented as \n.
CRLF (Carriage Return + Line Feed): Used by Windows. Represented as \r\n.
When you see ‘bash\r’, it means your system is trying to execute a file that has Windows-style line endings. The system reads bash plus that invisible carriage return (\r) as the name of the interpreter. Since there is no program actually named bash\r, it throws the "No such file or directory" error.
Fix
sed -i 's/\r$//' your_script_name.sh