Linux creates a script to check whether a folder exists or not.
This article mainly introduces linux in detail through the script to check whether the folder does not exist is created, the sample code introduced in the article is very detailed, has a certain reference value, interested friends can refer to it.
linux shell script check if folder exists create if not
Examples are as follows:
date_str=`date +%Y%m%d`dir=/root/crontab/logfunction run_mkcurrent_dir(){my_dir="$dir/$date_str"if [ ! -d "$my_dir" ]; then echo "Create folder" mkdir $my_direlse echo "folder already exists"fi}run_mkcurrent_dir;
The above is linux through the script to check whether the folder does not exist, the details of the creation, after reading whether there is any harvest? If you want to know more about it, welcome to Industry News.