Created
May 7, 2015 07:24
-
-
Save vmassuchetto/b13e42108303327e085f to your computer and use it in GitHub Desktop.
Shell script to count citations in TeX files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Counts the number of lines each citation appears on a tex file. | |
# | |
# Usage: | |
# | |
# ./countbib texfile.tex | |
# | |
TEXFILE=$1 | |
BIBFILE=$(cat $TEXFILE | grep "\\\bibliography" | sed "s/.*\\\bibliography{\(.*\)}.*/\1/g") | |
BIBENTRIES=$(cat "${BIBFILE}.bib" | grep "^@" | sed "s/^@.*{\(.*\)[^A-Za-z0-9]/\1/g") | |
COUNTLIST=$( | |
for BIB in $BIBENTRIES; do | |
LINECOUNT=$(grep $BIB $TEXFILE | wc -l) | |
printf "%4s %s\n" $LINECOUNT $BIB | |
done | |
) | |
echo "$COUNTLIST" | sort -n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment