2
2
I would like to list all the directories and sub directories in and below the current path. Since I only wanted to display directories I came up with the following command:
find -type d -exec ls -d1 {} \; | cut -c 3-
This prints out for example
webphone
music
finance
finance/banking
finance/realestate
finance/trading
finance/other
finance/moneylending
finance/insurance
webradio
webtv
The problem I have right now is, that the directory finance
is listed. finance
contains no files, just the sub directories you see above. What I want to achieve is the following output:
webphone
music
finance/banking
finance/realestate
finance/trading
finance/other
finance/moneylending
finance/insurance
webradio
webtv
In this list the directory finance
is not listed. Therefore I need your advice of how to filter directories which contain no files (only subdirectories).
why are you using
find -type d -exec ls -d1 {} \;
instead ofls -d1 */
? – phuclv – 2020-01-17T07:24:42.700