Script basics · Question 11 of 12

A script saved on Windows reports /bin/bash^M: bad interpreter on start. Which commands fix this?

2 answers are correct. Hard Created with AI

Show answer

Answer

  • A sed -i 's/\r$//' s.sh
  • D dos2unix s.sh

Explanation

Windows ends lines with \r\n, so the interpreter is named /bin/bash\r. dos2unix and the sed command remove the \r. A different interpreter would have the same problem.

Certifications & exams

Which exam comes next?

You can already practise for 51 exams, and 16 are up for a vote. See all certifications with their official information, cast your vote or suggest your exam.

See all certifications