From cbe042381c410ffd8a4cd3797e246a544996fce0 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Tue, 20 Feb 2024 15:35:00 -0800 Subject: [PATCH] sort results --- bin/vdns-zone-lst.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/vdns-zone-lst.sh b/bin/vdns-zone-lst.sh index 31fc322..302d45b 100755 --- a/bin/vdns-zone-lst.sh +++ b/bin/vdns-zone-lst.sh @@ -33,11 +33,12 @@ SEARCH=($(/usr/local/sbin/pdns-search.sh -q hostname=$hostname/$query -c)) # check for header row output, this indicates one or more results were found if [[ "${SEARCH[0]}" = "content,name,object_type,type,zone,zone_id" ]]; then + # sort results + readarray -td '' SORTED < <(printf '%s\0' "${SEARCH[@]}" | sort -z) # echo header and remove header row echo zone - SEARCH=("${SEARCH[@]:1}") # check each row to verify data and output zone (domain) if it validates - for ROW in "${SEARCH[@]}"; do + for ROW in "${SORTED[@]}"; do # turn row into array readarray -d , -t row_array < <(echo $ROW) # get zone, strip ending dot