From b186e5d6a1c335c9c16444341b7216226d02d627 Mon Sep 17 00:00:00 2001 From: Patrick McGuire Date: Wed, 29 Sep 2021 14:44:33 -0400 Subject: [PATCH] have birdstats.local (birdnet_stats.sh) working okay, not great --- scripts/birdnet_stats.sh | 7 ++++--- scripts/update_species.sh | 15 ++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/scripts/birdnet_stats.sh b/scripts/birdnet_stats.sh index 70fa88b..9b5ff88 100755 --- a/scripts/birdnet_stats.sh +++ b/scripts/birdnet_stats.sh @@ -23,13 +23,14 @@ else a=0 fi echo -SOFAR=$(wc -l ${IDFILE}| cut -d' ' -f1) +SOFAR=$(($(wc -l ${IDFILE}| cut -d' ' -f1)/2)) echo " -$a detections so far" echo echo " -$SOFAR species identified so far" +echo while read -r line;do - echo " + $line" -done < ${IDFILE} + echo " | $line" +done < <(awk -v n=2 '1; NR % n == 0 {print ""}' ${IDFILE}) echo echo -n "Listening since "${INSTALL_DATE}"" sleep 180 diff --git a/scripts/update_species.sh b/scripts/update_species.sh index d1c9214..c895543 100755 --- a/scripts/update_species.sh +++ b/scripts/update_species.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Update the species list -# set -x +#set -x trap 'rm -f "$TMPFILE"' SIGINT SIGTERM EXIT source /etc/birdnet/birdnet.conf @@ -11,14 +11,11 @@ TMPFILE=$(mktemp) || exit 1 IDFILEBAKUP="${IDFILE}.bak" -if [ $(find ${ANALYZED} -name '*txt' | wc -l) -ge 1 ];then - sort $(find ${ANALYZED} -name '*txt') \ - | awk '/Spect/ {for(i=11;i<=NF;++i)printf $i""FS ; print ""}' \ - | cut -d'0' -f1 \ - | sort -u > "$TMPFILE" - cat "$IDFILE" >> "$TMPFILE" - cp "$IDFILE" "$IDFILEBAKUP" - sort -u "$TMPFILE" > "$IDFILE" +if [ $(find ${PROCESSED} -name '*csv' | wc -l) -ge 1 ];then + sort $(find ${PROCESSED} ${ANALYZED} ${EXTRACTED} -name '*csv') \ + | awk -F\; '!/Scientific/ {print"Common Name: " $4 "\nScientific Name: " $3""}' \ + | uniq > "$TMPFILE" + cat "$TMPFILE" | awk '!visited[$0]++' > "$IDFILE" cat "$IDFILE" else cat "$IDFILE"