$ nmap -Pn -p993 imap.gmail.com |& grep -q 'Host is up' && { ... } And of course someday the printed text will change and I'll have to edit my scripts again! Oh well. :-/