#! /bin/sh - command -v squote_escape >/dev/null 2>&1 || { echo "${0} depends on squote_escape"; exit 1; } if [ -t 0 ] && [ -n "${1}" ]; then query='find "${HOME}"/.better_bash_history/ -type f -exec cat {} \+' while [ -n "${1}" ]; do [ "${1}" = "-" ] && { invert_flag="-v"; shift; [ -n "${1}" ] || { echo "${0}: syntax error: expected pattern after minus"; exit 2; } } || invert_flag="" query="${query} | grep ${invert_flag} -aF -- $(squote_escape "${1}")" shift done eval "${query} | uniq | nl" else echo "${0} is not a filter" fi