-1

I need to find all directories that begin with dirD in the directory /dirA/dirB/dirC. Basically, dirD*. So far I tried:

find . -type d -name "dirD*"

and

ls -lrt | grep "^d" | grep "dirD*"

Now I'm searching for these folders on a remote server I haven't used until now so there's a chance they might not be there. However, others who have worked on said server until now insist that they should be there so I was wondering if I'm missing something...

  • 1
    What's the problem? Do those commands not return anything? What directory did you run them in? Also, in future, please use the formatting tools. – terdon Oct 20 '16 at 11:10
  • yes, they don't return anything. i'm running them in dirC. didn't know about the formatting tools, i'll use them from now on. – kabras Oct 20 '16 at 11:16
  • 2
    OK, please edit your question and include that. It is hard to read and easy to miss in the comments. Also, comments can be deleted with no warning. Please also include the output of find /dirA/dirB/dirC -type d -name "dirD*". If that returns nothing, the directories aren't there. – terdon Oct 20 '16 at 11:21
  • grep "dirD*" doesn't do what you seem to think it does. It matches anywhere in the string for the three characters dir followed by zero or more characters D. (It is not a shell glob.) So it could match anotherdir or dirDDDDDD or even just dir. Read up on Regular Expressions for the detail. – roaima Oct 20 '16 at 12:45
-1

Inside any dir, run

ls -ld /dirA/dirB/dirC/dirD*

Or inside dirC, run

ls -ld dirD*

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.