Problem in using cut command

Hi Friend ,

i have one file say xyz.lst and it has content like

dn: cn=m.hariharan,cn=employee,cn=delhi circle,cn=users,dc=industowers,dc=c
dn: cn=ajay.jain,cn=employee,cn=gujarat circle,cn=users,dc=industowers,dc=com
dn: cn=ajitkumar.thakor,cn=employee,cn=gujarat circle,cn=users,dc=industowers,
dn: cn=abhinesh.sharma,cn=employee,cn=punjab & haryana circle,cn=users,dc=indu

now i uses unix cut command

 " cut -d ',' -f 1,3 xyz.lst"

and the result is

dn: cn=m.hariharan,cn=delhi circle
dn: cn=ajay.jain,cn=gujarat circle
dn: cn=ajitkumar.thakor,cn=gujarat circle

but my output should be like this.

m.hariharan delhi circle
ajay.jain  gujarat circle
ajitkumar.thakor  gujarat circle

i want to omit dn: cn= from name section and cn= from region section.

Any help is greatly appreciated.
Thanks in Advance.

Regards,
Harish Anand

Please open your own thread next time ( moved to create a new thread...) Thread Hijacking is not permitted here!

 <after your output> |sed 's/cn=//g ; s/dn://' 

I've slightly modified vbe's sed command to get the exact output required (no leading whitespace + whitespace instead of comma)

cut -d ',' -f 1,3 xyz.lst | sed 's/dn: cn=//; s/,cn=/ /'

sed only solution:

sed 's/dn: cn=//; s/,cn=employee,cn=/ /; s/,.*//' xyz.lst

s/dn: cn=// delete dn: cn=
s/,cn=employee,cn=/ / substitute ,cn=employee,cn= with a single whitespace
s/,.*// delete everything after the the comma (including the comma)

Hi,

This is my first answer. Please be gentle :). I tried the below code in my system that runs on centos7 and it worked.

 cat one
dn: cn=m.hariharan,cn=employee,cn=delhi circle,cn=users,dc=industowers,dc=c
dn: cn=ajay.jain,cn=employee,cn=gujarat circle,cn=users,dc=industowers,dc=com
dn: cn=ajitkumar.thakor,cn=employee,cn=gujarat circle,cn=users,dc=industowers,
dn: cn=abhinesh.sharma,cn=employee,cn=punjab & haryana circle,cn=users,dc=indu

awk -F'[=,]' '{print $2,$6}' one
m.hariharan delhi circle
ajay.jain gujarat circle
ajitkumar.thakor gujarat circle
abhinesh.sharma punjab & haryana circle

Let me know if this works for you. Thanks