当前位置: 移动技术网 > 科技>操作系统>Linux > Shell—常见报错问题

Shell—常见报错问题

2019年11月16日  | 移动技术网科技  | 我要评论

bash:$'\r': command not found

造成这个问题的原因是windows环境下换行的“\r”到了linux环境下不能够识别了,因为linux环境下默认的换行符为“\n”,我们只需要把文件转成unix就好。使用 dos2unix 工具实现该转换。

# 1.安装 dos2unix 工具
[root@localhost ~]# apt install dos2unix         # ubuntu系统
[root@localhost ~]# yum -y install dos2unix   # centos系统

# 2.转换文件
[root@localhost ~]# chmod 755 test.sh
[root@localhost ~]# dos2unix test.sh

# 3.再次执行文件就可以啦
[root@localhost ~]# sh ./test.sh

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网