Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 223

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report