Home>Article>Operation and Maintenance> Linux implementation checks whether the folder exists and creates it if it does not exist

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

王林
王林 Original
2020-02-14 16:57:55 6310browse

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!

Statement:
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