2020/12/07: An error was reported when Linux was running the file: bash: $'\r': command not found

Problems encountered

I got the .sh file packaged and written from Windows and unzipped it under Linux to run it. I encountered an bash: $'\r': command not founderror.

The reason for the error

This is because the file wrapping of the Windows system is used \r\n, while the Linux system is\n

Solution

# 使用vim打开文件
vim ***.sh
# 转换格式
:set ff=unix
# 保存文件
:wq

The problem is solved!

Guess you like

Origin blog.csdn.net/weixin_43624728/article/details/110835276