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

 

相关文章:

  • 2021-12-23
  • 2021-07-28
  • 2022-01-30
  • 2021-12-23
  • 2021-10-28
  • 2022-02-06
  • 2021-09-22
猜你喜欢
  • 2021-07-08
  • 2022-02-20
  • 2021-11-23
  • 2021-09-27
  • 2021-12-23
  • 2022-12-23
  • 2021-10-17
相关资源
相似解决方案