Fork me on Gitee

shell脚本报错:-bash: xxx: /bin/bash^M: bad interpreter: No such file or directory

shell脚本报错:-bash: xxx: /bin/bash^M: bad interpreter: No such file or directory

  1. 首先用vi命令打开文件 [root@localhost test]# vi shell1.sh

     #!/bin/bash
     echo $RANDOM |md5sum |cut -c 1-8
    
  2. 在vi命令模式中使用 :set ff 命令

    可以看到改文件的格式为dos

  3. 修改文件format为unix

    使用vi修改文件format

    命令:set ff=unix

  4. 执行完后再通过set ff命令查看文件格式

    wq保存即可

posted @ 2020-01-29 12:10  明叶师兄。  阅读(173)  评论(0编辑  收藏  举报