Added '--' to grep calls to protect patterns

This commit is contained in:
Trey Blancher 2017-12-27 10:11:11 -05:00
parent e6234010e5
commit 73e7359c63
1 changed files with 58 additions and 0 deletions

58
do_process Executable file
View File

@ -0,0 +1,58 @@
#!/bin/bash
ORGS=()
if [[ "x${1}" == "x" ]]; then
DATE=$(date +%F)
else
DATE=$1
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
[[ "${ORGS[@]}" =~ "${org}" ]] || ORGS+=("${org}")
done
}
get_list_of_orgs < ${DATE}.log
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=""
for pattern in "${ORGS[@]}" meeting; do
#echo "pattern=${pattern}" >&2
if [[ "${pattern}" == "meeting" ]]; then
grep -- "${pattern}" ${DATE}.log | grep -Ev -- "${WHOLE}" | timetracker
else
grep -- "${pattern}" ${DATE}.log | timetracker
fi
echo
if [[ "${WHOLE}x" == "x" ]]; then
WHOLE="${pattern}"
else
WHOLE="${WHOLE}|${pattern}"
fi
echo
done
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