【Bash 檔案處理 #2】bash 確認檔案存在 (bash if file exist)

#前言

用 bash 來確認檔案存不存在

範例

FILE=test.sh
if [ -f "$FILE" ]; then
    echo "$FILE exists."
else
    echo "$FILE not exists."
fi

結果

依照檔案存不存在會有不一樣的結果。

Reference