bash do not create file if empty result


tee empty file
use ifne
grep -ri website /etc/apache2 | ifne tee /tmp/outout.log

rm also can help:
grep -ri website /etc/apache2 > /tmp/outout.log ; [[ $? -ne 0 ]] && 'rm' -f /tmp/outout.log

Leave a Reply

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