Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux creates a script to check whether a folder exists or not.

Shulou Source: shulou.com Published: 2022-06-03 06:41:17 10月30日 Update

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.

Tags: Files folders scripts checks content references code value interests examples guys buddies that is more examples articles industries information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker vpn Shulou Technology OPPO Reno MySQL