目次推断:

    path="/home"
    #if [ ! -d ${path} ];then
    if [ -d ${path} ];then
        echo dir ${path} exist!
    else
        echo dir ${path} not exist!
    fi

免费进修视频教程分享:linux视频教程

文件推断:

    file="/home/log.txt"
    if [ -f ${file} ];then
        echo file ${file} exist!
    else
        echo file ${file} not exist!
    fi

相干文章教程引荐:linux教程

以上就是linux中怎样经由过程if语句推断文件或目次是不是存在的细致内容,更多请关注ki4网别的相干文章!