InstallScript icon indicating copy to clipboard operation
InstallScript copied to clipboard

.sh:行22: $'\r': 未找到命令

Open leangjia opened this issue 1 year ago • 1 comments

linux执行sh脚本报错:$’\r’: 未找到命令的解决

leangjia avatar Aug 29 '24 06:08 leangjia

When you see error messages like this:

-bash: '\r': command not found

Try running the dos2unix command on the file.

Why? Windows style newline characters cause this error in Linux.

The dos2unix command modifies the newline characters so they are Linux compatible.

(CAUTION: the dos2unix command modifies files in place, so take precaution if necessary. If you need to keep the original file, you should make a backup copy first.)

Then, you can run the .sh file without that error.

chris001 avatar Sep 01 '24 04:09 chris001