diff options
| author | Your Name <you@example.com> | 2024-04-05 10:34:44 +0200 |
|---|---|---|
| committer | Your Name <you@example.com> | 2024-04-05 10:39:09 +0200 |
| commit | e9d443ea7286fceea3c071988226a16c0d5b0b97 (patch) | |
| tree | 1266b96d377ed8c3ff3da150c9dc2f62f97214c2 | |
| parent | 55cf801ef5a46bff37219afe3ad3e16281e0bb03 (diff) | |
Improve error report
| -rw-r--r-- | .power_unique.sh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/.power_unique.sh b/.power_unique.sh index 25fb530..f05f392 100644 --- a/.power_unique.sh +++ b/.power_unique.sh @@ -5,7 +5,18 @@ while IFS= read -r line; do echo $line >> $tmp done +first_line=$(head -n1 $tmp|grep "timestamp,nsecs,power") # To check for validity last_line=$(cat $tmp | tail -n1) +ncomma=$(echo "$last_line" | tr -cd ',' | wc -c | tr -d ' ') # To check for validity + +# Check if measurements are valid (not perfect test but sufficient) +if [ -z "${first_line}" ] || [ $ncomma -ne 2 ] +then + cat $tmp + exit 100 +fi + +# If valid then proceed to uniqueness cat $tmp | awk -F"," 'BEGIN{LAST=-1;skipped=0} {if(LAST!=$3){print $1","$2","$3;skipped=0}else{skipped=1} LAST=$3} END{if(skipped){print "'$last_line'"}}' rm $tmp |
