Why executing script system prints "line X: $'\r': command not found"

Solution Unverified - Updated -

Issue

  • Running custom made script uploaded to the system ends up with errors
# ./script.sh
bash: ./script.sh: /bin/bash^M: bad interpreter: No such file or directory
#
# sh ./script.sh
script.sh: line 2: $'\r': command not found

Environment

  • Red Hat Enterprise Linux 6

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In