Separating output and diagnostics

Remember always to write error output from your script to the standard error file descriptor, not to output, using the >&2 redirection:

#!/bin/bash
if ! [[ -e $myfile ]] ; then
    printf >&2 '%s does not exist!\n' "$myfile"
    exit 1
fi

This allows users to redirect any output the script generates separately from the errors. This applies to non-fatal warnings or diagnostic information just as much as to error messages.