Introduction
Introduction Statistics Contact Development Disclaimer Help
Add bird name generator. - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit 16c27d94d49d535e49f1e1b55a0e50c705752c3c
parent 9c8048d9db15a8ebd91f787cbe4720e04a1b251d
Author: Annna Robert-Houdin <[email protected]>
Date: Sat, 2 Jan 2021 22:02:11 +0100
Add bird name generator.
Diffstat:
A bird-name | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/bird-name b/bird-name
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Original code by josuah. Thanks!
+#
+
+set -x
+
+birdsrc="https://www.birds.cornell.edu/clementschecklist/wp-content/uploads/20…
+
+# Cache dir for bird name csv.
+tmpdir="/home/annna/tmp"
+
+[ -f ${tmpdir}/bird.csv ] || curl "$birdsrc" \
+ | awk -F "," '
+ NR == 1 { for (f = 1; f <= NF && $f != "SCI_NAME"; f++); }
+ NR > 1 { gsub(/[[(].*[])]/, ""); sub(".* ", "", $f) }
+ length($f) > 3 && length($f) <= 6 && !F[$f]++ { print $f }
+' > ${tmpdir}/bird.csv
+
+# Get two names so it sounds more intellectual.
+awk -v r=$RANDOM '
+ BEGIN { srand(r) } { bird[NR] = $0 }
+ END { print bird[int(rand() * NR)] " " bird[int(rand() * NR)]; }
+' ${tmpdir}/bird.csv
+
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.