Thursday 6 March 2014

Listing only Directory in Linux


The following commands will list all of the sub directories in the present directory,



ls -d */ | xargs -l basename

ls -d */ | cut -d/ -f1

ls -d */ | cut -f1 -d'/'

ls -p | grep "/" | cut -f1 -d'/'


echo */ | cut -f1 -d'/'


find . -maxdepth 1 -mindepth 1 -type d -printf %P\\n

find . -mindepth 1 -maxdepth 1 -type d  \( ! -iname ".*" \) | sed 's|^\./||g'

find [!.]* -maxdepth 0 -type d


for f in *;do if [[ -d $f  ]]; then echo $f;fi; done;


No comments:

Post a Comment