Handling filenames with spaces in a bash for or while loop
// Note: OS X `find` does not support "-depth 1" (its -depth opt is for depth-first searching vs. breadth-first), just use an 'ls' with an 'if [ -d $filename]' to test for directories
find ~ -type d -depth 1 | while read filename; do # ls ~ | while read filename; do echo $filename # other stuff done