hi
How can i list files which are only folders in Unix
Tuan
hi
How can i list files which are only folders in Unix
Tuan
find . -type d -print
-print is the default. "." is also the default directory. So you can get away with
("d" means of type "directory") orCode:find -type d
Note that find is recursive -- it will show you subdirectories and so on too. If you just want a list of directories in the current directory, you can use something like this.Code:find path -type d
That gives you the long filename listing, however, which you may not want. If you just want the filenames, you could use something like this:Code:ls -l | grep ^d
I'm sure there's a cleaner way, but if there is, it escapes me at the moment.Code:for file in *; do [ -d "$file" ] && echo $file; done
Last edited by dwks; 04-04-2008 at 07:32 PM.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.