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 found
error.
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