On Sat, Nov 06, 2021 at 12:32:14AM +0100, richard lucassen wrote: > > > postqueue -j | jq -nr --argjson days $days ' > > > ... > > I have run the jq script for a week or so ($days = 5) and it works like > a charm :-)
You're welcome. Of course if the number of days will never vary in your case, it would be simpler to just hard-code the number into the jq script: # postqueue -j | jq -nr ' (now - 86400 * 5) as $too_old | inputs | select(.queue_name == "hold" and .arrival_time < $too_old) | .queue_id | select(test("^\\w+$")) ' | postsuper -d - hold Making it an external variable was intended to facilitate use via shell functions that might take the day count as an option, and perhaps even an optional list of queue names: old_qids() { local OPTARG OPTIND=0 days=5 while getopts hd: opt do case $opt in h) echo "Usage: old_qids [-h] [-d <days>] [all | <queue> ...]" >&2 return 1;; d) days=$OPTARG;; *) return 1;; esac done shift $(( OPTIND - 1 )) postqueue -j | jq -nr --argjson days "$days" ' (now - 86400 * $days) as $too_old | $ARGS.positional as $qs | inputs | select(.arrival_time < $too_old) | first(select($qs == [] or {(.queue_name,"all"):true}[$qs[]])) | .queue_id | select(test("^\\w+$")) ' --args -- "$@" } -- Viktor.