Home > Enterprise >  Unix command: ls -d */ but i only want to see the folders, not the files
Unix command: ls -d */ but i only want to see the folders, not the files

Time:12-01

I am on UNIX environment. What I want to achieve is to navigate to a directory, and print out all its folders. For example:

/user/Mike/data/

In the above directory, it has 50 folders. I want to only see the 50 folders in this directory. I used the following command:

ls -d */

However, it will also show all the files within this directory. Is there a way for us to eliminate the listing for files by using my command above?

CodePudding user response:

2 options that I can think of:

ls -l | grep ^d, but this stats the output.

find * -maxdepth 0 -type d

  •  Tags:  
  • unix
  • Related