From cc9909a0c736267ab6d76bd291fffdcee4b218cc Mon Sep 17 00:00:00 2001 From: Trey Blancher Date: Fri, 5 Oct 2018 17:26:08 -0400 Subject: [PATCH] Allow spaces and sort organization names --- do_process | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/do_process b/do_process index 545e088..cc2a8d1 100755 --- a/do_process +++ b/do_process @@ -10,16 +10,19 @@ fi if [[ -f ${DATE}.log ]]; then get_list_of_orgs () { - orgs=$( grep -Po "\s+\[.*\]" | tr -d '[][]' ) - for org in ${orgs}; do - org="${org##*( )}" # trim leading whitespace - org="${org%%*( )}" # trim trailing whitespace + while read; do + org=$( grep -Po "\s+\[.*\]" <<< "${REPLY}" | tr -d '[][]' | xargs ) + [[ "${org}x" == "x" ]] && continue +# org="${org##*( )}" # trim leading whitespace +# org="${org%%*( )}" # trim trailing whitespace [[ "${ORGS[@]}" =~ "${org}" ]] || ORGS+=("${org}") done } get_list_of_orgs < ${DATE}.log + IFS=$'\n'; ORGS=($(sort -f <<< "${ORGS[*]}")); unset IFS + for (( i=0; i < ${#ORGS[@]}; i++ )); do echo "ORGS[$i]=${ORGS[$i]}" done