Listing only directories in UNIX

前端 未结 20 877
青春惊慌失措
青春惊慌失措 2020-12-12 09:40

I want to list only the directories in specified path (ls doesn\'t have such option). Also, can this be done with a single line command?

20条回答
  •  情深已故
    2020-12-12 10:21

    You can use the tree command with its d switch to accomplish this.

    % tree -d tstdir
    tstdir
    |-- d1
    |   `-- d11
    |       `-- d111
    `-- d2
        `-- d21
            `-- d211
    
    6 directories
    

    see man tree for more info.

提交回复
热议问题