ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I think cmontr's idea to let a directory service be a directory service is the best idea. I'm not running an ldap service to I cant test his example.
Code:
sed -n '/ou=consumer/,/clinkid/{
/dn: uid=/s/.*uid=\([^,]*\), .*/\1/p
/clinkid/s/clinkid://p
}' input.ldif >output.txt
Since the UID is listed twice, I don't know which value you wanted. One is in uppercase and the other in lower.
Also, if you only post one record, you could be hiding a pattern that can be used to delineate record.
For example, look at the output of "/sbin/lspci -v". Since each output record is separated by a blank line, it's possible to extract a record using a Broadcom device:
Code:
/sbin/lspci -v | sed -n '/Broadcom/,/^$/p'
03:0a.0 Network controller: Broadcom Corporation BCM4306 802.11b/g Wireless LAN Controller (rev 03)
Subsystem: Linksys Device 0015
Flags: bus master, fast devsel, latency 32, IRQ 18
Memory at fddfc000 (32-bit, non-prefetchable) [size=8K]
Kernel driver in use: b43-pci-bridge
Kernel modules: ssb
I think cmontr's idea to let a directory service be a directory service is the best idea. I'm not running an ldap service to I cant test his example.
Code:
sed -n '/ou=consumer/,/clinkid/{
/dn: uid=/s/.*uid=\([^,]*\), .*/\1/p
/clinkid/s/clinkid://p
}' input.ldif >output.txt
Since the UID is listed twice, I don't know which value you wanted. One is in uppercase and the other in lower.
Also, if you only post one record, you could be hiding a pattern that can be used to delineate record.
For example, look at the output of "/sbin/lspci -v". Since each output record is separated by a blank line, it's possible to extract a record using a Broadcom device:
Code:
/sbin/lspci -v | sed -n '/Broadcom/,/^$/p'
03:0a.0 Network controller: Broadcom Corporation BCM4306 802.11b/g Wireless LAN Controller (rev 03)
Subsystem: Linksys Device 0015
Flags: bus master, fast devsel, latency 32, IRQ 18
Memory at fddfc000 (32-bit, non-prefetchable) [size=8K]
Kernel driver in use: b43-pci-bridge
Kernel modules: ssb
I appreciate for the try ...It partially works ..I have done this with awl earlier...when it prints, it prints all "ou's" with the clinkid's. But I need only the ones with ou=consumer with along their clinkid's...it is a bit confusing...Please let me know if you have an idea. thanks much again.
I appreciate for the try ...It partially works ..I have done this with awl earlier...when it prints, it prints all "ou's" with the clinkid's. But I need only the ones with ou=consumer with along their clinkid's...it is a bit confusing...Please let me know if you have an idea. thanks much again.
I tried this but it didnt bring what I needed ...any ideas someone please let me know..
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.