Windows → Linux

Bash says “No such file,” but the file exists

A script copied from Windows may contain CRLF endings. The hidden carriage return can corrupt the shebang or an argument and produce a misleading missing-file error.

Updated July 11, 2026 · 5 min

Inspect without changing

file deploy.sh
cat -v deploy.sh | head

If you see CRLF, ^M, or /bin/bash^M, line endings are the likely cause.

RiskBack up the target script before conversion. Do not run bulk replacements across an unknown directory.

Repair only the target

sed -i 's/\r$//' deploy.sh

Then verify the shebang and executable permission. You can also invoke the interpreter explicitly with bash deploy.sh.

Success checks

  • file no longer reports CRLF.
  • cat -v shows no ^M.
  • A minimal command runs before the full deployment is retried.