Home>Article>Operation and Maintenance> Linux implementation checks whether the folder exists and creates it if it does not exist
linux shell script checks whether the folder exists and creates it if it does not exist
The example is as follows: (Related learning video sharing:linux video tutorial)
date_str=`date +%Y%m%d` dir=/root/crontab/log function run_mkcurrent_dir(){ my_dir="$dir/$date_str" if [ ! -d "$my_dir" ]; then echo "创建文件夹" mkdir $my_dir else echo "文件夹已存在" fi } run_mkcurrent_dir;
Recommended related tutorials:linux tutorial
The above is the detailed content of Linux implementation checks whether the folder exists and creates it if it does not exist. For more information, please follow other related articles on the PHP Chinese website!