export MYP="identity '([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,})'" EMAIL=`grep -B15 "$DATE" $LOGFILE | grep "$CONID" | grep identity | perl -nle 'print "$1" if /$ENV{MYP}/'` #### Apr 29 10:01:10 vpn.example.com charon: 07[NET] received packet: from 2.204.0.13[55842] to 27.3.213.112[4500] (80 bytes) Apr 29 10:01:10 vpn.example.com charon: 14[IKE] received EAP identity 'jd@example.com' Apr 29 10:01:11 vpn.example.com charon: 14[IKE] EAP-MS-CHAPv2 verification failed, retry (1)