Shell Error: bash: ./a.sh: /bin/bash^M: bad interpreter: No such file or directory [How to Solve]

The shell script written under Windows environment is uploaded to Linux for execution, and an error is reported

-bash: ./databasebak.sh: /bin/bash^M: bad interpreter: No such file or directory

It is suspected that there is a problem with the file format. Use vi databasebak.sh to enter the databasebak.sh file, and then execute it in the bottom mode  : set ff   Check it and find that fileformat = DOS. Look, it’s really a file format problem

Solution: after entering VI databasebak.sh, in the bottom mode, execute: set fileformat = UNIX and then execute: X or: WQ to save the changes. Then you can execute./databasebak.sh to run the script.

Similar Posts: