Home > Article > Operation and Maintenance > How to determine whether a file or directory exists through an if statement in Linux
Directory judgment:
path="/home" #if [ ! -d ${path} ];then if [ -d ${path} ];then echo dir ${path} exist! else echo dir ${path} not exist! fi
Free learning video tutorial sharing: linux video tutorial
File judgment:
file="/home/log.txt" if [ -f ${file} ];then echo file ${file} exist! else echo file ${file} not exist! fi
Recommended related articles and tutorials: linux tutorial
The above is the detailed content of How to determine whether a file or directory exists through an if statement in Linux. For more information, please follow other related articles on the PHP Chinese website!