vcf2cnt/cnt2vcf

41 lines
774 B
Bash
Executable File

#!/bin/sh
set -e
read -p 'Nome: ' name
read -p 'Cognome: ' surname
read -p 'Cellulare: ' cellphone
read -p 'Indirizzo: ' address
read -p 'Email: ' email
read -p 'Telefono: ' phone
read -p 'XMPP: ' xmpp
read -p 'Note: ' note
printf 'BEGIN:VCARD\r\n'
printf 'VERSION:4.0\r\n'
printf 'N:%s;%s;;;\r\n' "$surname" "$name"
printf 'FN:%s %s\r\n' "$name" "$surname"
if [ -n "$cellphone" ]; then
printf 'TEL;TYPE=CELL:%s\r\n' "$cellphone"
fi
if [ -n "$email" ]; then
printf 'EMAIL;TYPE=HOME:%s\r\n' "$email"
fi
if [ -n "$phone" ]; then
printf 'TEL;TYPE=HOME:%s\r\n' "$phone"
fi
if [ -n "$xmpp" ]; then
printf 'IMPP;TYPE=HOME:xmpp:%s\r\n' "$xmpp"
fi
if [ -n "$note" ]; then
printf 'NOTE:%s\r\n' "$(echo "$note" | sed 's/\\/\\\\/g;s/,/\\,/g')"
fi
printf 'END:VCARD\r\n'