[linux shell]if -else 例子

#ifelse_exam.sh腳本用於檢查輸入的字符串是否是一個當前目錄
#!/bin/bash

#測試用戶輸入是否爲空,然後判斷當前目錄是否存在該文件

if [ "$1" ]
then 
        echo "What you input is not null"
        if [ -e "$1" ]
        then 
                echo "The file $1 is existence!"
        else
                echo "The file $1 is not existence!"
        fi
else 
        echo "What you input is null!"
fi


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章