LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-27-2012, 05:40 AM   #1
KaRt
LQ Newbie
 
Registered: Jul 2012
Location: india
Posts: 28

Rep: Reputation: Disabled
Wink 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

Last edited by KaRt; 07-27-2012 at 05:49 AM.
 
Old 07-27-2012, 05:47 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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.
 
Old 07-27-2012, 05:53 AM   #3
KaRt
LQ Newbie
 
Registered: Jul 2012
Location: india
Posts: 28

Original Poster
Rep: Reputation: Disabled
Input line:Username:Firstname:Lastname:Telephone number
 
Old 07-27-2012, 05:58 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Code:
awk -F: '{ print "dn: uid="$1", dc=example, dc=com" ; print "cn: "$2, $3 ; print "sn: "$3 ; print "telephoneNumber: "$4 ; print "" }' infile
 
1 members found this post helpful.
Old 07-27-2012, 06:03 AM   #5
KaRt
LQ Newbie
 
Registered: Jul 2012
Location: india
Posts: 28

Original Poster
Rep: Reputation: Disabled
thanks druuna its worked
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] awk script to pull out last record sarenace Linux - Newbie 13 04-02-2012 01:45 AM
awk: How can I keep the format of the record? quanba Programming 5 04-05-2010 09:50 PM
awk command line: blank line record sep, new line field sep robertmarkbram Programming 4 02-21-2010 05:25 AM
[SOLVED] split multi line record into multiple files with awk pcock Programming 10 11-12-2009 04:12 AM
[SOLVED] Simple Linux script to convert datetime format to UTC format shayno90 Linux - Newbie 10 10-09-2009 08:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration