📌  相关文章
📜  shell if "-z" - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:49:36.781000             🧑  作者: Mango

代码示例2
# Returns true if string empty.
# E.G: file.txt does not exist

EXISTS=$(cat file.txt 2> /dev/null)

if [ -z "${EXISTS}" ]; then
    echo "Does not exist"
else
    echo "Exist!"
fi

# Output: 
# Does not exist