Solaris find (ls) tip: List all directory in current path without search sub-directory
Last week, one of my colleague ask me how to list all directories which only in current path. I made a litter research, and have learned these find tips.
- List current directory name without slash "/"
[myPC]$find * -prune -type d
- List current directory name with slash "/"
[myPC]$ls -F|grep ‘/’
- List current directory name in long format with slash "/"
[myPC]$ls -l |grep ^d
Sometimes when you maybe need list all files in current path without search sub-directory
[myPC]$find . \( -type d ! -name . -prune \) -o \( -type f -print \)
[myPC]$find * -prune -type f
by using -type you can list any type file which you want. It can be followed :b, c, d, D, f, l, p, or s for block special file, character special file, directory, door, plain file, symbolic link, fifo (named pipe), or socket, respectively. For more details, please see find man page.