#!/bin/bash ############### # DESCRIPTION: remove mails with 'X-Virus-Status: Infected' from mailq ############### set -euo pipefail DEL="" for ID in $(mailq 2>/dev/null |grep -Eo '^[0-9A-Z]+'); do [[ -n "$(postcat -q $ID |grep 'X-Virus-Status: Infected')" ]] && DEL+="$ID\n" done [[ -n "$DEL" ]] && printf "$DEL" |postsuper -d-