In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How to judge the existence of folders or files in shell? in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
Create if the folder does not exist
If [!-d "/ data/"]; thenmkdir / dataelseecho "folder already exists" fi
Delete if the file exists
If [!-f "/ data/filename"]; thenecho "File does not exist" elserm-f / data/filenamefi
Determine whether the folder exists
If [- d "/ data/"]; thenecho "folder exists" elseecho folder does not exist "fi"
Determine whether the file exists or not
If [- f "/ data/filename"]; thenecho "file exists" elseecho "file does not exist" fi
File comparator
-e determines the existence of the object-d determines the existence of the object, and judges the existence of the object for the directory-f, determines the existence of the object for the regular file-L, and judges the existence of the object for the symbolic link-h, and judges the existence of the object for the soft link-s, and determines the existence of the object for the length not 0murr, and determines whether the object exists for readable-w. And can write-x to determine whether the object exists, and executable-O to determine whether the object exists, and belongs to the current user-G to determine whether the object exists. And belongs to the current user group-nt to determine whether file1 is newer than file2 ["/ data/file1"-nt "/ data/file2"]-ot to determine whether file1 is older than file2 ["/ data/file1"-ot "/ data/file2"] this is the answer to the question about how to determine whether a folder or file exists in shell. I hope the above content can be helpful to you, if you still have a lot of questions unsolved. You can follow the industry information channel for more related knowledge.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.