71 lines
982 B
Bash
71 lines
982 B
Bash
|
#! /bin/bash
|
||
|
|
||
|
# address takes two arguments: a flag what to do as $1 and a handle to handle as $2
|
||
|
H=$2
|
||
|
F=$1
|
||
|
O=false
|
||
|
LOC=""
|
||
|
COL=""
|
||
|
|
||
|
if [ $# -lt 2 ]
|
||
|
then
|
||
|
echo "Zu wenig Argumente"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [ $# -gt 2 ]
|
||
|
then
|
||
|
echo "Ignoriere überschüssige Argumente"
|
||
|
fi
|
||
|
|
||
|
if [ $F = "-n" ]
|
||
|
then
|
||
|
COL=Name
|
||
|
O=true
|
||
|
fi
|
||
|
|
||
|
if [ $F = "-a" ]
|
||
|
then
|
||
|
COL=Anrede
|
||
|
O=true
|
||
|
fi
|
||
|
|
||
|
if [ $F = "-d" ]
|
||
|
then
|
||
|
COL=Adresse
|
||
|
O=true
|
||
|
fi
|
||
|
|
||
|
if [ $F = "-f" ]
|
||
|
then
|
||
|
# return fax number to be used by sipgate-cli
|
||
|
COL=FaxNr
|
||
|
O=true
|
||
|
fi
|
||
|
|
||
|
if [ $F = "-t" ]
|
||
|
then
|
||
|
COL=TelNr
|
||
|
O=true
|
||
|
fi
|
||
|
|
||
|
if [ $F = "-c" ]
|
||
|
then
|
||
|
COL=Closing
|
||
|
O=true
|
||
|
fi
|
||
|
|
||
|
if [ $F = "-p" ]
|
||
|
then
|
||
|
COL=parent
|
||
|
O=true
|
||
|
fi
|
||
|
|
||
|
if [ $O ]
|
||
|
then
|
||
|
LOC=$(head -1 Adressen.csv | tr ',' '\n' | nl |grep -w "$COL" | tr -d " " | awk -F " " '{print $1}') #calculating position of requested Col
|
||
|
grep "$H" Adressen.csv | cut -d "," -f$LOC | head -n 1 | sed 's/"//g'
|
||
|
#Returning requested column, making sure to return only one result (even though redundant results shouldn't be possible)
|
||
|
fi
|
||
|
|