shell-utils/app/contacts
2023-07-15 20:21:25 +01:00

13 lines
490 B
Bash
Executable File

#!/usr/bin/env zsh
addressbook="/home/gmgauthier/.local/share/addrbook/contacts.txt"
## Simple record retrieval by any known value
#awk 'BEGIN { RS = "<->" } /'$*'/' $addressbook
## Get record by search for substring in email
#awk 'BEGIN { RS = "<->"; FS = "email: " } ($2 ~ "'${*}'") { print $0 }' $addressbook
## Get email addresses in a specific contact class
awk 'BEGIN { RS = "<->"; FS = "category: " } ($2 ~ "'${1}'") { print }' $addressbook | grep '^email:' | egrep -o '[^ ]+$'