Marius van Witzenburg "Learned my lesson in life, now setting my action to stay in life."

10Mar/100

List only directories on the command-line or in your scripts

Here you have some different ways of showing only the directories on a path you specify.
This can be used in different other languages such as PHP with shell_exec for example.

ls -l /shares/ | grep "^d" | awk '{ print $9 }'
find /shares/ -maxdepth 1 -mindepth 1 -type d | sed 's/.\///g'
find /shares/ -maxdepth 1 -mindepth 1 -type d | perl -pi -e 's/.\///g'
find /shares/ -maxdepth 1 -mindepth 1 -type d | grep -v '^\./\.'

I hope you find them useful on some way :-)
Of course comments are more than welcome!

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.