summaryrefslogtreecommitdiff
path: root/bibsum
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2020-01-05 16:12:08 +0000
committerKatolaZ <katolaz@freaknet.org>2020-01-05 16:12:08 +0000
commit879a7f0eb3393778a2a37aa1bee8cbd16f61814f (patch)
treee7ce242f393bf85f93acd50233f5f4caee0ffa63 /bibsum
parente0d092afafaed0abb80e7dd448379abf7562cd8d (diff)
add bibsum
Diffstat (limited to 'bibsum')
-rwxr-xr-xbibsum26
1 files changed, 26 insertions, 0 deletions
diff --git a/bibsum b/bibsum
new file mode 100755
index 0000000..8e59e54
--- /dev/null
+++ b/bibsum
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#
+# Print summaries of bibtex entries in tsv format given as input
+# showing only the requested fields
+#
+
+if [ $# -lt 1 ]; then
+ printf "Usage: %s <field> [<field>...]\n" $0
+ exit 1;
+fi
+
+fields=$(echo "$@" | sed -E 's/([a-zA-Z0-9]+)/\1.\*=|/g;s/\ //g')
+fields=$(echo "$fields" | sed -E 's/\|$//')
+
+##echo "$fields"
+
+IFS='
+'
+
+while read -r line; do
+ name=$(echo "$line" | cut -f 1)
+ attrall=$(echo "$line" | cut -f 2-)
+ attrs=$(echo "$line" | tr '\t' '\n' | sort | grep -E -ai "($fields)" | tr '\n' '\t' | sed -E 's/\ +/ /g')
+ printf "%s\t%s\t}\n" $name $attrs
+done