当前位置:   article > 正文

shell脚本报错:-bash: xxx: /bin/bash^M: bad interpreter: No such file or directory_-bash: keytool -importcert -keystore 没有那个文件或目录

-bash: keytool -importcert -keystore 没有那个文件或目录

第一次写shell脚本,然后在执行的时候报错,如下:

  1. [root@localhost ~]# ./mysql5.6.44-install-auto.sh
  2. -bash: ./mysql5.6.44-install-auto.sh: /bin/bash^M: bad interpreter: No such file or directory

主要原因是test.sh是我在windows下编辑然后上传到linux系统里执行的。.sh文件的格式为dos格式。而linux只能执行格式为unix格式的脚本。

我们可以通过vi编辑器来查看文件的format格式。步骤如下:

1.首先用vi命令打开文件

[root@localhost ~]# vi mysql5.6.44-install-auto.sh 

2.在vi命令模式中使用 :set ff 命令

:set ff

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

fileformat=dos

3.修改文件format为unix

使用vi修改文件format

命令:set ff=unix

:set ff=unix

 

执行完后再通过set ff命令查看文件格式,结果如下:

fileformat=unix

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/743991
推荐阅读
相关标签
  

闽ICP备14008679号