<code>
if cd $dir/.libs
then nm ... | egrep ... || echo "Squeaky clean :-)"
fi </code>

It's a good idea to ensure that there's at least *some* output for each $dir.
Checking that cd works is harmless and hygienic.