Linux implementation checks whether the folder exists and creates it if it does not exist

王林
Release: 2020-02-14 16:57:55
Original
6407 people have browsed it

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;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template