First off, that isn't how you pipe something to grep. Also, you may wantit is generally considered better form to separate the grepcommands from the conditional and just check its return codecodes.
Something like the following works perfectly:
command=`ls -l`
for file in "$command"
do
echo "$file" | grep 'o'
if [ $? -eq 0 ]; then
echo "$file"
fi
done