ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I recently read latest article on Linux.com on "CLI Magic: Command-line contact management" and am trying to make the example there work for a CLI-based reader of KDE's addressbook.
Currently I can grep the ~/.kde/share/apps/kabc/std.vcf, but is it possible to use awk to grep for a name or email address, and then have it print the entire record between the tags BEGIN:VCARD and END:VCARD ?
I'm not familiar with the layout of these vcf files. Could you post an example (2 or 3 records are enough)? Would possibly make it a lot easier to help you
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 459
Rep:
Can u try the following pseudo-code? (A possible algorithm). Assumes that the input data format is text (not having ascii > 127) and on knwn format.
(1) sequentially read the data file until EOF.
(2) If BEGIN:VCARD, then append the line to a variable.
(3) If email or name matches, then set a flag.
(4) If END:VCARD, examine the flag and if on (search criteria was matched), then dump the array. Initialise the array, reset the flag and loop back to step 1.
(5) on EOF, examine the flag and if on, dump the array.
I'm not familiar with the layout of these vcf files. Could you post an example (2 or 3 records are enough)? Would possibly make it a lot easier to help you
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.