OS commands to list only the directories in Linux or Unix

Sometimes a folder may contains 1000s of files and few directories and if we want to list only directories within a folder in UNIX and Linux, these commands can become helpful.

ls -l | egrep '^d'




Another easy way to perfom is to create an alias (I prefer this):

alias ldir="ls -l | egrep '^d'"





Another method to list only directory is using find command.

find . -type d

No comments:

Post a Comment