You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
754 B
33 lines
754 B
#!/usr/bin/env sh
|
|
|
|
log=${HOME}/bloodpressure_log.csv
|
|
timezone=America/Chicago
|
|
|
|
#Sanity check
|
|
# Log sanity
|
|
if [ ! -f $log ]; then
|
|
echo "Date/Time,Systolic,Diastolic,Pulse,Comment" > $log
|
|
elif ! (head -n 1 $log | grep -E '^Date' >/dev/null 2>&1); then
|
|
sed -i '1 i\Date/Time,Systolic,Diastolic,Pulse,Comment' $log
|
|
fi
|
|
# Syntax sanity
|
|
if [ $# -eq 0 ]; then
|
|
column -s, -t < $log
|
|
exit 0
|
|
fi
|
|
if [ $# -lt 3 ]; then
|
|
echo Wrong number of arguments\! >&2
|
|
echo "Usage: bp [systolic] [diastolic] [pulse] <comment>" >&2
|
|
exit 1
|
|
fi
|
|
#End sanity check
|
|
|
|
sys=$1
|
|
dia=$2
|
|
pulse=$3
|
|
comment=$4
|
|
|
|
echo Logged to $log\:
|
|
echo $(TZ=$timezone date +%Y-%m-%d\ %H\:%M),${sys},${dia},${pulse},${comment} >> $log && sed -n '1p;$p' $log | column -s, -t && exit 0
|
|
|