Basic phonebook via BASH

bash grep

I’d like to write about the super cool bash technique I learned from a training video of 2011.

Yes, you can implement super basic phonebook application via shell script. Create a file called: phonebook

# phonebook

#!/usr/bin/env bash

# name phone-number
# name phone-number
# name phone-number
# name phone-number

grep -i $* <<EOF
vigo  0123-456-78-99
jack  0123-456-78-99
max   0123-456-78-99
turbo 0123-456-78-99
EOF

then make it executable: chmod +x phonebook. Now make query!

$ ./phonebook vigo
vigo 0123-456-78-99

Thanks to Carl Albing for Great Bash course at Safaribooks