$‘\r‘: command not found 出错

Linux 下运行脚本 常见错误之一 $’\r’: command not found 出错

问题

在这里插入图片描述

在Windows下编写好sh文件后,在Linux下运行会报错:bash: $’\r’: command not found

这是因为Windows系统的文件换行使用的是\r\n,而Unix系统是\n

解决

只需要在Linux下使用vim打开文件,然后使用命令:set ff=unix即可

# 使用vim打开文件
vim aaa.sh
:set ff=unix
:wq

在这里插入图片描述
Down!

你可能感兴趣的:(Linux,linux,r语言,bash)