zoukankan      html  css  js  c++  java
  • Linux学习笔记之Linux shell脚本运行出现问题:bash: ./test: bin/sh: bad interpreter: No such file or directory

    问题:

    在Linux系统中使用“vi test.sh”命令创建.sh文件,保存文件(:wq)并赋予权限(chmod +x test.sh)后,执行(./test.sh),出现问题:“bash: ./test: bin/sh: bad interpreter: No such file or directory”

    test.sh文件代码如下:

    #!bin/sh

    str="hello world"

    echo $str

    echo "shell,${str}"


     

    解决办法如下:

    1、首先检查代码内容,发现由于粗心“#!bin/sh”出错,修改为“#!/bin/sh”,再运行一遍看。

    2、其次检查文件的属性,代开文件输入:“:set ff”,可以看到dos或unix的字样。如果的确是dos格式的,那么你可以用set ff=unix把它强制为unix格式的,然后存盘退出,再运行一遍看。

  • 相关阅读:
    Network(树形dp)洛谷2899
    2590 树的统计
    LCT 最小生成树
    几种贪心小结
    snmp
    div页面跳转
    2017.11.2总结,回顾及成果
    2017.11.1知识总结及回顾
    check,form,单选框与复选框总结
    HTML空格字符
  • 原文地址:https://www.cnblogs.com/sunshine-blog/p/7814549.html
Copyright © 2011-2022 走看看