Using locate to only find directories containing the string "foo"
Maybe a litte tricky but here it comes:
locate foo | xargs file -NF '|' |grep '| directory' | sed 's/| directory//g'
Locate only reads preprepared databases and not the filesystem.
Using find
directories containing foo
find /path -name '*foo*' -type d
links that contain foo, you need to read the link and test to see if the destination is a directory which requires a script
#!/bin/bash
f=$(readlink $1)
if [ -d "$f" ]
then
echo $1
fi
use it like this
find /path -name '*foo*' -type l -exec script {} \;
locate foo | sed 's%/[^/]*$%/%'
Edit: This just snaps all info out after the last slash.