Using bash, how do I write an if statement that checks if a certain directory, stored in the a script variable named “$DIR”, contains child directories that are not “.” or “..”?
Thanks, – Dave
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As the comments have pointed out, things have changed in the last 9 years! The dot dirs are no longer returned as part of find and instead the directory specified in the
findcommand is.So, if you want to stay with this approach:
(originally accepted answer from 2011)