Test if a string has a period in it with bash
You can use pattern matching:
for i in $(drush site-alias) ; do
if [[ $i == *.* ]] ; then
drush "$i" command
fi
done
With any Bourne-like shell, you'd write it:
case $i in
*.*) drush "$i" command;;
esac
You can do this with a pattern replace expansion:
for i in $(drush site-alias); do
if [ -z "${i//[^.]/}" ]; then
# no period
drush "$i" command
fi
done
Yes, I quoted "$i"
, which is probably something you should do when possible, it avoids surprises. Though in this case it won't matter.