LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   awk script that will convert such a line to an LDAP record in this format (https://www.linuxquestions.org/questions/linux-newbie-8/awk-script-that-will-convert-such-a-line-to-an-ldap-record-in-this-format-4175418920/)

KaRt 07-27-2012 05:40 AM

awk script that will convert such a line to an LDAP record in this format
 
Input line:Username:Firstname:Lastname:Telephone number

record output:

dn: uid=Username, dc=example, dc=com
cn: Firstname Lastname
sn: Lastname
telephoneNumber: Telephone number

pixellany 07-27-2012 05:47 AM

What is the question??
From the title, we can GUESS that you have some data that you want to convert to the format shown.---If so, then you need to show us what the data looks like.

KaRt 07-27-2012 05:53 AM

Input line:Username:Firstname:Lastname:Telephone number

druuna 07-27-2012 05:58 AM

Code:

awk -F: '{ print "dn: uid="$1", dc=example, dc=com" ; print "cn: "$2, $3 ; print "sn: "$3 ; print "telephoneNumber: "$4 ; print "" }' infile

KaRt 07-27-2012 06:03 AM

thanks druuna its worked


All times are GMT -5. The time now is 09:02 AM.