Allow spaces and sort organization names

This commit is contained in:
Trey Blancher 2018-10-05 17:26:08 -04:00
parent 5d17f2cbe1
commit cc9909a0c7
1 changed files with 7 additions and 4 deletions

View File

@ -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