Last active
September 11, 2023 16:49
-
-
Save shollingsworth/3c9399fee286d7cad988f38483bb2d8a to your computer and use it in GitHub Desktop.
iterate through postfix queue and selectively delete entries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
mapfile -t ids < <(mailq | grep -E '^[0-9A-F]' | awk '{print $1}') | |
for id in "${ids[@]}"; do | |
postcat -q "${id}" | less | |
echo "Remove? (y)" | |
read -r RM | |
RM=$(echo "${RM}" | tr '[:upper:]' '[:lower:]') | |
if [[ "${RM}" = "y" ]]; then | |
echo "Deleting ${id}" | |
postsuper -d "${id}" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment