Solve the problem of Linux server execution -bash: ./xxx.sh: /bin/sh^M: bad interpreter: No such file or directory

I. Overview

Today in the windows environment by Ideawriting shella script, it performs the following error after uploading packages to linux environment:

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

2. The cause of the problem

This problem is due to write in the windows shellat the end of the descriptor file is dosunder the command can not be executed under linux.
You can view it through the following steps.

1. Execute the command:

vim xx.sh

2. Finally you can see it in the opened file, as shown below. You can see that the end of this document is.dos
Insert picture description here

Three, the solution

Solution one

The steps are as follows:
1. Execute the following command to open the document.

vim xx.sh

2. Execute the following commands to modify the terminator

:set ff=unix

3, execute wqsave the file.

Solution two

It can be directly ideamodified. As shown below, first select the file.
Insert picture description here

Solution three

It can be solved by notepad++, as shown below
Insert picture description here

The English version of notepad++ is Edit> EOL Conversion> Unix(LF)

Solution four

Solved by eclipse. First you need to select the file
Insert picture description here

Guess you like

Origin blog.csdn.net/small_love/article/details/112991460