Honesty Rocks! truth rules.

Showing All Folders On Unix

HOME      >>       Software

toby

I want to get the name of every folder but not any files in one volume, on Mac OSX 10.5.6. The best idea I can think of is some mix of ls/find and grep/awk, but even with google and man I can't work much out. I got to ls -Rl and awk '{ print $NF }' > file but they don't work together well. Any ideas? It can be a program, I just looked for unix commands first.


yordan

If it's pure Unix or Linux, I would try the following :

find . -type d -print
"find" will look for everything starting from the current position (".") in order to display it ("-print"), provided that it's type ("-type") is "d" (directory).
I just tried it on my Unix system and it works fine.

toby

Ty, perfect. I shall learn about find, it's new to me.


yordan

Ty, perfect. I shall learn about find, it's new to me.

I use "find" very often.for instance, if you want to perform a backup of a given folder and put it on your tape, you use find this way :
find . -print |cpio -omBdv >/dev/rmt0
And if you want to copy the whole content of your folder to the remote resource which is nfs-mount on /mnt, use the following :
find . -print |cpio -pmdulv /mnt/myfolder
Which means that you have to simultaneously learn "find" and "cpio" syntax... :mellow: