timetracker/do_process

58 lines
1.3 KiB
Plaintext
Raw Normal View History

#!/bin/bash
ORGS=()
if [[ "x${1}" == "x" ]]; then
DATE=$(date +%F)
else
DATE=$1
fi
if [[ -f ${DATE}.log ]]; then
get_list_of_orgs () {
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
#for org in "${ORGS[@]}"; do
# echo ${org}
#done
echo "--"
echo ${DATE}
echo
echo
echo
WHOLE=""
2018-10-08 12:43:32 -04:00
for pattern in "${ORGS[@]}"; do
#echo "pattern=${pattern}" >&2
2018-10-08 12:43:32 -04:00
grep -- "${pattern}" ${DATE}.log | timetracker
echo
if [[ "${WHOLE}x" == "x" ]]; then
WHOLE="${pattern}"
else
WHOLE="${WHOLE}|${pattern}"
fi
echo
done
2018-10-08 12:43:32 -04:00
grep -Ev "${WHOLE}" ${DATE}.log | timetracker
echo
timetracker ${DATE}.log | grep "Section" | sed 's/Section/Grand/'
else
echo "${DATE}.log does not exist" >&2
fi