bash中,命令没有找到 [英] bash, command not found

查看:1674
本文介绍了bash中,命令没有找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在这个bash脚本修复错误,我认真不知道我做错了什么,任何帮助是AP preciated感谢

  [centoslive @的LiveCD〜] $ SH ListFich.sh测试
SYNTHESE,问题2
ListFich.sh:9号线:[-d:命令未找到
伊尔n'y一个aucun剧目本身魁测试nomme
ListFich.sh:第15行:[-f:命令未找到
伊尔n'y一个aucun fichier魁本身nomme测试
[centoslive @的LiveCD〜] $

 #!斌/庆典回声合成及其性能,问题2如果测试$#-eq 0;然后
    回声参数Manquants
    1号出口
其他
    如果[-d $ 1];然后
        LS -d $ 1
        1号出口
    其他
        回声伊尔n'y一个aucun剧目本身魁nomme $ 1
    科幻
    如果[-f $ 1];然后
        如果[-s $ 1];然后
            ls -l命令$ 1
            1号出口
        其他
            ls -l命令$ 1
            回声乐fichier $ 1 EST韦迪
            1号出口
        科幻
    其他
        回声伊尔n'y一个aucun fichier魁本身nomme $ 1
    科幻
科幻


解决方案

添加一个空格 [之前 ]

  [-D $ 1]
 ^^

i'm having trouble fixing the error in this bash script, I seriously have no idea what I did wrong, any help is appreciated thanks

[centoslive@livecd ~]$ sh ListFich.sh test
Synthese, Question 2
ListFich.sh: line 9: [-d: command not found
Il n'y a aucun repertoire qui se nomme test
ListFich.sh: line 15: [-f: command not found
Il n'y a aucun fichier qui se nomme test
[centoslive@livecd ~]$ 

#!bin/bash

echo "Synthese, Question 2"

if test $# -eq 0; then
    echo "Argument Manquants"
    exit 1 
else 
    if [-d $1];then
        ls -d $1
        exit 1
    else 
        echo "Il n'y a aucun repertoire qui se nomme $1"
    fi
    if [-f $1]; then
        if [ -s $1]; then
            ls -l $1
            exit 1
        else 
            ls -l $1
            echo "Le fichier $1 est vide"
            exit 1
        fi
    else 
        echo "Il n'y a aucun fichier qui se nomme $1"   
    fi
fi

解决方案

Add a space after [ and before ].

[ -d $1 ]
 ^     ^

这篇关于bash中,命令没有找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆