How do I read data from my Address Book card from the command line?

1

From a Mac OS command line, I'm looking for a command that will read my address book card and print my email address to stdout.

Doing it via an osascript command would be fine.

John

Posted 2011-08-23T18:39:42.030

Reputation: 111

Answers

2

What you are looking for is contacts.

The utility contacts gives you access to view and search all your records in the AddressBook database.

Without further ado, here are a few examples:

$ contacts -h
usage: contacts [-hHsmnlS] [-f format] [search]
      -h displays help (this)
      -H suppress header
      -s sort list
      -m show me
      -n displays note below each record
      -l loose formatting (doesn't truncate record values)
      -S strict formatting (doesn't add space between columns)
      -f accepts a format string (see man page)

displays contacts from the AddressBook database

fideli

Posted 2011-08-23T18:39:42.030

Reputation: 13 618

0

ABFind from iHarder is your friend.

contacts (as mentioned in the other answer is great app, but its not compatible to osx versions newer than 10.7

ABFind runns just fine on 10.11 and returns a sort-of json response

http://iharder.sourceforge.net/current/macosx/abfind/

Nullx8

Posted 2011-08-23T18:39:42.030

Reputation: 11

How does it work in 10.11 when its not compatible with OS versions never than 10.7 ? – pun – 2016-01-23T10:46:16.973

1as i wrote "ABFind runns just fine on 10.11", contacts does not. – Nullx8 – 2016-01-23T16:24:47.030

@pun "contacts" (CLI app) != "Contacts" (MacOS built-in app). – Tom Hundt – 2019-07-25T23:49:44.127

ABFind not working for me on 10.14.5. – Tom Hundt – 2019-07-25T23:50:14.600