Wednesday, November 05, 2008

List only directories/files in Linux

If only list directories:
ls -d */

you can also use:
ls -l | grep ^d
tree -d -L 1
echo */  

list the hide directory with
ls -d .*/

if only list the files, use:
ls -l | grep ^-
ls -l | grep -v ^d

if only list hidden files, use:
ls -a | grep ^'\.'

create alias by adding following lines to .bash_profile
alias lsd="ls -d */"
alias lsf="ls -l | grep -v ^d"

No comments:

Post a Comment