![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
awk and sed
Hi All,
Can any help me in sorting out the below problem say file abc.txt.Z contains paa_databasket: { ac=sfs, hkaf=jgh, cellid=113, name=sfs, appid=4862355, camid=24244, add=nfsadkf sfs, dbuid=1145, code=2424 } paa_databasket: { ac=sfs, hkaf=jgh, cellid=131, name=sfs, appid=4535864, camid=24234, dbuid=5515, add=nfsadkf sfs, code=5524 } paa_databasket: { ac=sfs, hkaf=jgh, cellid=161, name=sfs, appid=424824, camid=242399, add=nfsadkf sfs, dbuid=5122, code=2424 } paa_databasket: { ac=sfs, hkaf=jgh, cellid=121, name=sfs, appid=244864, camid=24242, add=nfsadkf sfs, code=2434, dbuid=5675 } ...... Output =========== cellid=113 appid=4862355 camid=24244 dbuid=1145 cellid=131 appid=4535864 camid=24234 dbuid=5515 cellid=161 appid=4248243 camid=24239 dbuid=5122 cellid=121 appid=2448643 camid=24242 dbuid=5675 Please help me getting the solution for the above problem thanks Satish |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
nawk -f thad.awk abc.txt
thad.awk: Code:
BEGIN {
n=split("cellid appid camid dbuid", arrNames, " ")
}
NF {
for(i=1; i <= n; i++) {
match($0, arrNames[i] "=[0-9][0-9]*")
printf("%s%c", substr($0, RSTART, RLENGTH), (i<n) ? " " : "\n")
}
}
|
|
#3
|
|||
|
|||
|
vgersh99,
Thanks for quick reply but Sorry to say , i didn't get required output for the above mentioned. I am not getting the cellid and appid is not totally is displayed. Can any one please help me in this.... Thanks Satish |
|
#4
|
||||
|
||||
|
Quote:
Code:
cellid=113 appid=4862355 camid=24244 dbuid=1145 cellid=131 appid=4535864 camid=24234 dbuid=5515 cellid=161 appid=424824 camid=242399 dbuid=5122 cellid=121 appid=244864 camid=24242 dbuid=5675 |
|
#5
|
|||
|
|||
|
vgersh99,
The command and script you provided are working fine according to the my input file specified. In my input file cellid, appid ,campid,dbuid are jumble in the string i.e placed anywhere in the string and appid is a 40characters long. appid is displaying only 2 or 3 char. and the no output. I think the problem is with input file. I will the correct input file. Thanks for your help Thanks Satish |
|
#6
|
||||
|
||||
|
just out of curiousity..... post a sample of your 'real' input file [if possible]
|
|
#7
|
|||
|
|||
|
vgersh99,
Thanks for your support , I got the required output using the java program. Thanks Satish |
|||
| Google The UNIX and Linux Forums |