Hi All,
I have a AIX file system with a folder structure like this
/1
/1/2
/1/2/3/5
/1/2/3/2
/2
/2/3/4
/2/5/6
I would like to list subdirectories
/1/2/3/5
/1/2/3/2
/2/3/4
/2/5/6
Can you please help me with this issue.
Thanks in advance.- Kavin
Hello Kavin,
Please do use code tags for commands/codes you are using in your posts as per forum rules, following may help you in same.
find -mindepth 2 -type d -printf '%P\n'
Above command will look for minimum 2nd level of directory structure and for maximum level of inner sub directories. But if you want to fix minimum and maximum directory levels you can do following for an example.
find -mindepth 2 -maxdepth 3 -type d -printf '%P\n'
Hope this helps.
Thanks,
R. Singh
Try:
find . -type d -depth | awk '!($0 in A); { sub("[/][^/]*$",x); A[$0]}'
---
Note: -maxdepth
and -printf
options to the find command are extensions and GNU find only (so not available as standard on AIX).
you can use below command to get all the sub directories - It will not list you single directory under a parent directory.
find . -type d -print | awk -F "/" '{if(NF>"2"){print $0};}'
HTH!!
A few years ago I posted this "smoking" solution
find . -depth -type d | awk -F/ 'NF>=prev {print} {prev=NF}'
1 Like
Thanks guys for the response. The command worked perfectly for me.
Thanks for the feedback. Which command are you referring to? There are several in this thread...