In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Today, the editor shares with you the method of using if to determine the existence of a directory in Linux. I believe many people do not know much about it. In order to make you understand better, I have summarized the following contents for you. Let's look down together. I'm sure you'll get something.
How Linux uses if to determine whether a directory exists
The methods are as follows:
1. The method of judging the existence of a directory by using if in the script
#! / bin/bashif [- d "c"]; then echo "directory c exists" else echo "directory does not exist" fi
Recommended: Linux tutorial column
2. Simple and convenient writing method
#! / bin/bash [- d "c"] & & echo "directory c exists" # or [- d "d"] | | echo "directory d does not exist"
More judgment formats are as follows:
-e filename if filename exists, true-d filename if filename is directory, true-f filename if filename is regular file, true-L filename if filename is symbolic link, true-r filename if filename is readable, true-w filename if filename is writable, true-x filename if filename executable, true-s filename if file length is not 0, true-h filename if file is soft link
These are the details of the method of using if to determine the existence of a directory in Linux. Have you gained anything after reading it? If you want to know more about it, welcome to the industry information!
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: 0
*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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.