Tag: Folder file exists and dir file directory parameter is judged
#shell判断文件夹是否存在 # If the folder does not exist, create a folder if [!-D "/myfolder"]; Then Mkdir/myfolderfi#shell determine the file, whether the directory exists or has permissions folder= "/var/www/" file= "/var/www/log" #-x parameter to determine $folder Whether it exists and has enforceable permissions if [!-X ' $folder]; Then mkdir the "$folder" fi#-D parameter to determine if there is an IF [!-D "$folder"]; then mkdir "$folder" fi#-F parameter to determine if $file exists if [! -F "$file"]; Then touch "$file" fi#-N to determine if a variable has a value if [!-n "$var"]; then echo "$var is empty" exit 0fi# determine if two variables are equal if ["$va R1 "=" $var 2 "]; Then echo ' $var 1 eq $var 2 ' else echo ' $var 1 not EQ $var 2 ' fi
Shell determines whether a file or folder exists