1

I am trying to make a BASH script to test the files in the working directory and return the files that are directory files.

One approach that I can think of is, starting with ls and feeding the output into test -d.

I'm not sure what sort of looping would be best for testing each variable. And, how I can design the loop so that it can handle an unlimited amount of input from ls, not just designed for a maximum of say 20 variables.

5

Don't parse the output of ls.

Instead, use find(1):

find . -type d

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.