Linux基础之去掉windows中的\r

linux换行为\n,windows换行为\r\n,windows环境编辑的shell脚本在linux下执行会报错:

line 2: $'\r': command not found

查看

# cat -A test.sh
#!/bin/sh^M$
^M$
...

解决方法:

vi

1)替换

:%s/^M//g

2)设置文件格式

:set fileformat=unix

 

posted @ 2019-05-30 15:50  匠人先生  阅读(2662)  评论(0)    收藏  举报