-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuat-vcf.sh
executable file
·36 lines (32 loc) · 974 Bytes
/
buat-vcf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# use a 'here document' to create the Vcard format
## add/remove Vcard fields between the 'EOM' start/end marks
#function create_vcard {
#cat << EOM
#BEGIN:VCARD
#VERSION:3.0
#FN:customer name
#N:$NAMA_KONTAK
#TEL;TYPE=CELL:${CELL_NUMBER}
#EMAIL;TYPE=PREF:${EMAIL_KONTAK}
#END:VCARD
#EOM
#}
###
IN_FILE=$1
#NAMA_KONTAK=$(awk '{print $1}')
#CELL_NUMBER=$(awk '{print $2}')
#EMAIL_KONTAK=$(awk '{print $3}')
TOTAL_BARIS_IN=$(wc -l ${IN_FILE})
TOTAL_BARIS_OUT=$(wc -l ${OUT})
## if IN_FILE missing show usage
if [[ "${IN_FILE}" == "" ]] ; then printf "\n\tUsage: $0 Input_file_name\n\n" ; exit 1 ; fi
OUT=${IN_FILE}.vcf
## if OUT already exists then rename
if [[ -e ${OUT} ]] ; then mv ${OUT} ${OUT}.last ; fi
awk '{print "BEGIN:VCARD\nVERSION:3.0\nFN:"$1"\nN:"$1"\nTEL;TYPE=CELL:"$2"\nEMAIL;TYPE=PREF:"$3"\nEND:VCARD"}' ${IN_FILE} > ${OUT}
#create_vcard >> ${OUT}
echo "total baris input ${TOTAL_BARIS_IN}"
echo "total baris output ${OUT}"
ls -l ${OUT}
exit 0