Forum Discussion
Ping_Xiong_1567
Apr 18, 2012Historic F5 Account
convert ldapsearch result into external datagroup format
Hi Guys, I come cross a
requirement to convert a txt file into external datagroup format in background. The source file is
the result from ldapsearch, something like this: ...
hooleylist
Apr 18, 2012Cirrostratus
And an even simpler awk example from James Quinby:
awk 'BEGIN{RS=" \n";FS="\n"};{print $3,$4}' input.txt | awk '{print "\042"$2"\042 := \042"$4"\042,"}'
First awk breaks the records by blank-lines (RS) and the fields (FS) by newlines – this prints the last 2 lines of each record side-by-side.
Second awk splits by spaces and prints the correct fields, delimiter and double-quotes.
N.B.: The sample input was a space on a blank line between records – you’ll want to adjust the RS in that first awk accordingly if the actual record separator is a true bare linefeed. This could probably be combined into a single awk script.
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects