Linux: /bin/bash^M: bad interpreter: No such file or directory

Shell script was saved with Windows CRLF (`\r\n`) line endings.

Runs locally in browser Free · No login Independently Verified 2026-11-25 v4.0.0
Identifier: Linux: /bin/bash^M: bad interpreter: No such file or directory Platform: Linux

Interactive Diagnostic Checklist

Safe Diagnostic Command:
file script.sh

Technical Explanation

Shell script was saved with Windows CRLF (`\r\n`) line endings. Verified technical resolution: Convert to Unix LF line endings (`sed -i "s/\r$//" script.sh`) and enforce `.gitattributes` `eol=lf`.

Worked Examples

  • Diagnostic check: file script.sh

Limitations & Assumptions

  • Confirm exact software version and execution layer before applying configuration changes in production.

Source References & Verification

Resource ID: err-linux-sed-crlf-shebang · Independently verified: 2026-11-25

Related Resources