#!/bin/csh -f

#directory with contacts 
set contacts=/home/jiri/mycontacts/b77f94ce-cd6c-ee95-1e4c-dd9172f217df


#find contact
set isnumber=`echo $1|awk '{if($1 ~ "^[+0-9][+0-9]*$") print 1; else print 0;}'`
if ($isnumber != 1) then
	echor -r must enter number
	exit 1
else
	set found=`grep -il '^TEL.*:.*'$1 $contacts/*.vcf`
	 if ( ${#found} == 0 ) then
                echor -r number $1 not found
                exit 1
        endif
	if ( ${#found} > 1 ) then
                set alternatives=`grep '^TEL.*:' $found | awk -F: '{print $3}'`
                echor -r number $1 not unique, choose between: $alternatives
                exit 1
        endif
	set name=`grep '^N:.*;;;' $found|awk -F: '{print $2}'|head -1|tr ';' ' '`
endif

echo $name $found
