sort results

This commit is contained in:
Matthew Saunders Brown 2024-02-20 15:35:00 -08:00
parent cb80288042
commit cbe042381c

View File

@ -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 # 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 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 header and remove header row
echo zone echo zone
SEARCH=("${SEARCH[@]:1}")
# check each row to verify data and output zone (domain) if it validates # 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 # turn row into array
readarray -d , -t row_array < <(echo $ROW) readarray -d , -t row_array < <(echo $ROW)
# get zone, strip ending dot # get zone, strip ending dot