summaryrefslogtreecommitdiff
path: root/super.sh
blob: 36e02c6cd202a6b5ff26c8cec5f7c79245a9cf36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/bash
# SJP 9 Nov 2021
#
# Append the argument to a file, with datestamp

theDate=$(\date -I)     # ISO 8601, natch

# Where to store the log file
logFile=~/box/leger/etc/superLog.txt

# to log a value, the user must include it as an argument
if [ -z $1 ]
    then 
        echo "Usage: provide an argument for super.sh to append to the log"
        exit 1
fi

if [ $1 != "tail" ]
   then
      echo $theDate,$1 >> $logFile
      #printf '%s,%s\n' $theDate ,$1   >> $logFile
fi

# Note: double quote expression to preserve carriage returns (thanks, stackoverflow)
echo "$(tail ${logFile})"