Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix script - egrep

Status
Not open for further replies.

rrrirvine

MIS
Oct 19, 2001
7
US
Hi..

I have text file which has info like below.
name=abcd
fullName:abcd xyzw
cn:xyz

name=abcd1
fullName:abcd1 xyzw2
cn:xyz1

name=abcd2
fullName:abcd2 xyzw2
cn:xyz2

etc
etc

and it is large text file.

Now i want to grab the only info od cn: and fullName: info in to seperate file each in one line.

so output file will be looks like below.
xvz abcd,xyzw
xvz1 abcd1,xyzw1
xvz2 abcd2,xyzw2


can anybody help be appreciated.

Thanks,
 
A starting point:
Code:
awk -F: '/^fullName:/{f=$2}/^cn:/{print $2,f}' /path/to/input > output

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks

I was doing this on solaris box:
# cat textfile |egrep "^cn: " | awk '{print $2}'

and it works fine but how to retrieve 'fullName' filed info at the same time in it will be in format described above for output.

thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top