#!/bin/sh

# Public domain notice for all NCBI EDirect scripts is located at:
# https://www.ncbi.nlm.nih.gov/books/NBK179288/#chapter6.Public_Domain_Notice

flags="f"
if [ -n "$*" ]
then
  flags=$( echo " $*" | sed 's/[^bfinrs]//g' )
  if [ -z "$flags" ]
  then
    flags="s"
  fi
fi
grep '.' |
sort "-$flags" |
uniq -i -c |
awk '{ n=$1; sub(/[ \t]*[0-9]+[ \t]/, ""); print n "\t" $0 }'
