diff options
-rwxr-xr-x | bibsum | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -19,8 +19,12 @@ 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 -aEi "($fields)" | tr '\n' '\t' | sed -E 's/\ +/ /g') - printf "%s\t%s\t}\n" $name $attrs + line=${line##[[:blank:]]} + if [ -n "$line" ]; then + name=$(echo "$line" | cut -f 1) + attrall=$(echo "$line" | cut -f 2-) + attrs=$(echo "$line" | tr '\t' '\n' | sort | grep -aEi "($fields)" | \ + tr '\n' '\t' | sed -E 's/\ +/ /g;s/\t+/\t/g') + printf "%s\t%s}\n" $name $attrs + fi done |