Skip to content

Instantly share code, notes, and snippets.

@schallis
Created December 30, 2010 10:29
Show Gist options
  • Save schallis/759659 to your computer and use it in GitHub Desktop.
Save schallis/759659 to your computer and use it in GitHub Desktop.
Grep through a \n terminated list of people and phone extensions
# Quick Bash function lookup for telephone extensions
tel() {
list=~/usr/share/phone-extensions.txt
if [ ! $1 ]
then
# Show all if no argument specified
cat $list | less
else
# Use agrep if available
type -p agrep &>/dev/null && grepper="agrep -1" || grepper="grep"
echo "$grepper -i $* $list" | bash -;
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment