#!/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 [...]\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