Bash: Run command if exists, else echo blank

Useful if you want to only output something if a command exists.

For example, I use this on my Proxmox hypervisors with ZFS to get status. Not all my hypervisors have zfs arrays. Makes it easy to blanket ssh to all hypervisors and get zfs status if it exists. For a custom status page I wrote.

 

Leave a Reply

Your email address will not be published. Required fields are marked *