2018-10-19 10:04:23 -04:00
|
|
|
#!/Users/tblancher/homebrew/bin/bash
|
2017-12-27 10:11:11 -05:00
|
|
|
|
2019-02-25 10:09:01 -05:00
|
|
|
PATH=/Users/tblancher/bin:/Users/tblancher/homebrew/opt/coreutils/libexec/gnubin:/usr/bin:/bin
|
2020-01-15 11:21:45 -05:00
|
|
|
grep=/Users/tblancher/homebrew/opt/coreutils/libexec/gnubin/grep
|
2019-02-25 10:09:01 -05:00
|
|
|
|
2018-10-19 10:04:23 -04:00
|
|
|
declare -A ORGS
|
2017-12-27 10:11:11 -05:00
|
|
|
|
2018-10-19 10:04:23 -04:00
|
|
|
#set -x
|
2017-12-27 10:11:11 -05:00
|
|
|
if [[ "x${1}" == "x" ]]; then
|
2020-04-02 16:46:48 -04:00
|
|
|
DATE=$(date +%F).log
|
2017-12-27 10:11:11 -05:00
|
|
|
else
|
|
|
|
DATE=$1
|
|
|
|
fi
|
|
|
|
|
2020-04-02 16:46:48 -04:00
|
|
|
if [[ -f ${DATE} ]]; then
|
2018-10-19 10:04:23 -04:00
|
|
|
find_existing_org () {
|
|
|
|
for org in ${ORGS[@]}; do
|
|
|
|
[[ "${org}" == "${1}" ]] && return 0
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
2017-12-27 10:11:11 -05:00
|
|
|
get_list_of_orgs () {
|
2018-10-05 17:26:08 -04:00
|
|
|
while read; do
|
2020-04-03 17:06:41 -04:00
|
|
|
org=$( $grep -Po "\[.*\]" <<< "${REPLY}" | tr -d '[][]' )
|
2018-10-05 17:26:08 -04:00
|
|
|
[[ "${org}x" == "x" ]] && continue
|
|
|
|
# org="${org##*( )}" # trim leading whitespace
|
|
|
|
# org="${org%%*( )}" # trim trailing whitespace
|
2018-10-19 10:04:23 -04:00
|
|
|
# [[ "${ORGS[@]}" =~ "^${org}$" ]] || ORGS+=("${org}")
|
|
|
|
# find_existing_org "${org}" || ORGS+=("${org}")
|
|
|
|
ORGS["${org}"]=1
|
2017-12-27 10:11:11 -05:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2020-04-02 17:03:42 -04:00
|
|
|
get_list_of_orgs < ${DATE}
|
2017-12-27 10:11:11 -05:00
|
|
|
|
2018-10-19 10:04:23 -04:00
|
|
|
# IFS=$'\n'; KEYS=($(sort -f <<< "${!ORGS[@]}")); unset IFS
|
|
|
|
KEYS=()
|
|
|
|
while IFS= read -rd '' key; do
|
|
|
|
KEYS+=( "${key}" )
|
|
|
|
done < <(printf '%s\0' "${!ORGS[@]}" | sort -f -z)
|
2018-10-05 17:26:08 -04:00
|
|
|
|
2018-10-19 10:04:23 -04:00
|
|
|
# for (( i=0; i < ${#ORGS[@]}; i++ )); do
|
|
|
|
for org in "${KEYS[@]}"; do
|
|
|
|
echo "[${org}]"
|
2017-12-27 10:11:11 -05:00
|
|
|
done
|
2018-10-19 10:04:23 -04:00
|
|
|
|
|
|
|
# for org in "${!ORGS[@]}"; do
|
|
|
|
# echo "[${org}]"
|
|
|
|
# done
|
2017-12-27 10:11:11 -05:00
|
|
|
|
|
|
|
echo "--"
|
|
|
|
echo ${DATE}
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
WHOLE=""
|
2018-10-19 10:04:23 -04:00
|
|
|
for pattern in "${KEYS[@]}"; do
|
2017-12-27 10:11:11 -05:00
|
|
|
#echo "pattern=${pattern}" >&2
|
2020-04-02 17:03:42 -04:00
|
|
|
$grep -- "\[${pattern}\]" ${DATE} | timetracker
|
2017-12-27 10:11:11 -05:00
|
|
|
echo
|
|
|
|
if [[ "${WHOLE}x" == "x" ]]; then
|
|
|
|
WHOLE="${pattern}"
|
|
|
|
else
|
|
|
|
WHOLE="${WHOLE}|${pattern}"
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
done
|
2020-01-15 11:32:22 -05:00
|
|
|
#$grep -Ev "${WHOLE}" ${DATE}.log | timetracker
|
2017-12-27 10:11:11 -05:00
|
|
|
echo
|
2020-04-02 17:03:42 -04:00
|
|
|
timetracker ${DATE} | $grep "Section" | sed 's/Section/Grand/'
|
2017-12-27 10:11:11 -05:00
|
|
|
|
|
|
|
else
|
2020-04-02 17:03:42 -04:00
|
|
|
echo "${DATE} does not exist" >&2
|
2017-12-27 10:11:11 -05:00
|
|
|
fi
|
2018-10-19 10:04:23 -04:00
|
|
|
|
|
|
|
#set +x
|