[Gllug] Locating Subdirectories
doug at pigeonhold.com
Tue Jul 27 12:43:53 UTC 2004
Mick Farmer wrote:
> I need to obtain the names of all the subdirectories in the
> current directory. I'm currently using the following.
> find * -type d -maxdepth 0
> Does anyone have anything simpler?
These days I tend to use python rather then shell for most things where
I would once have used shell, just because it's so much cleaner when
your tiny script inevitably grows to take over the known universe.
In python your statement would be:
[ x for x in os.listdir('.') if os.path.isdir(x) ]
Which i reckon is neater than anything in any shell :)
http://adju.st/ | "If you want to know about governments,
6973E2CF: 2C95 66AD | all you have to know is two words:
1596 37D2 41FC 609F | Governments lie." -- I. F. Stone
76C0 A4EC 6973 E2CF |
Gllug mailing list - Gllug at gllug.org.uk
More information about the GLLUG