![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| search ")" with egrep - egrep: syntax error | sagarjani | UNIX for Dummies Questions & Answers | 7 | 10-14-2008 07:30 AM |
| egrep/grep result of more files | tvrman | Shell Programming and Scripting | 3 | 08-07-2008 08:29 AM |
| Egrep cheat sheet anywhere? Looking for meaning of egrep -c | leelm | UNIX for Dummies Questions & Answers | 2 | 01-11-2008 03:37 PM |
| perl - copying files | BG_JrAdmin | Shell Programming and Scripting | 1 | 12-13-2007 09:50 PM |
| Perl Uploading Files | sstevens | UNIX for Advanced & Expert Users | 16 | 02-24-2004 03:03 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Perl or awk/egrep from big files??
Hi experts.
In one thread i have asked you how to grep the string from the below sample file- Unfortunately the script did not gave proper output (it missed many strings). It happened may be i did gave you the proper contents of the file That was the script- "$ perl -00nle'print join "\n", /<fullOperation>(.*?):.*<fullResult>(.*?);/s' filename.txt" Now for you convinience i paste contents here from the begining of the file- Output of the below file would be- CREATE RESP:-3010 DELETE RESP:0 CREATE RESP:911364896 GET RESP:0 SET RESP:911265678 <?xml version='1.0' encoding='ISO-8859-1' standalone='no'?> <LogItems> <log logid="83efeae5190811100759420954"> <category>Upstream.CAI</category> <operation>Login</operation> <target>CAI</target> <instance></instance> <user></user> <context></context> <fullOperation>LOGIN:server1:eri4ema</fullOperation> <starttime>20081110075942.366900</starttime> <stoptime>20081110075942.424451</stoptime> <fullResult>RESP:3001;</fullResult> <status>FAILED</status> </log> <log logid="83efeae5190811100759480955"> <category>Upstream.CAI</category> <operation>Login</operation> <target>CAI</target> <instance></instance> <user></user> <context></context> <fullOperation>LOGIN:server1:eri4ema;</fullOperation> <starttime>20081110075948.375669</starttime> <stoptime>20081110075948.375923</stoptime> <fullResult>RESP:3007;</fullResult> <status>FAILED</status> </log> <log logid="83efeae5190811100759580956"> <category>Upstream.CAI</category> <operation>Login</operation> <target>CAI</target> <instance></instance> <user>server1</user> <context>sog</context> <fullOperation>LOGIN:server1:*******;</fullOperation> <starttime>20081110075958.354986</starttime> <stoptime>20081110075958.355238</stoptime> <fullResult>RESP:0;</fullResult> <status>SUCCESSFUL</status> </log> </LogItems> <?xml version='1.0' encoding='ISO-8859-1' standalone='no'?> <LogItems> <log logid="83efeae5190811100802020957"> <category>Upstream.CAI</category> <operation>Get</operation> <target>ESUB</target> <instance>CODE=432350114484630</instance> <user>server1</user> <context>sog</context> <fullOperation>GET:ESUB:CODE,432350114484630;</fullOperation> <starttime>20081110080202.185236</starttime> <stoptime>20081110080202.834500</stoptime> <fullResult>RESP:11000003;UNKNOWN SUBSCRIBER;</fullResult> <status>FAILED</status> </log> </LogItems> <?xml version='1.0' encoding='ISO-8859-1' standalone='no'?> <LogItems> <log logid="83efeae5190811100802120958"> <category>Upstream.CAI</category> <operation>Get</operation> <target>DSUB</target> <instance></instance> <user>server1</user> <context>sog</context> <fullOperation>GET SUB:MDN,989352375449;</fullOperation><starttime>20081110080212.352053</starttime> <stoptime>20081110080213.376720</stoptime> <fullResult>RESP:0:MDN,989352375449:CODE,432350114484630:COUNTRY,FI:LANG,fi:PRE,0:SUBNAME,Eserve:MMS ,1;</fullResult> <status>SUCCESSFUL</status> </log> </LogItems> <?xml version='1.0' encoding='ISO-8859-1' standalone='no'?> <LogItems> <log logid="83efeae5190811100802350959"> <category>Upstream.CAI</category> <operation>Get</operation> <target>ACCOUNTINFORMATION</target> <instance></instance> <user>server1</user> <context>sog</context> <fullOperation>GET:ACCOUNTINFORMATION:SubscriberNumber,989352375449;</fullOperation> <starttime>20081110080235.264165</starttime> <stoptime>20081110080235.555880</stoptime> <fullResult>RESP:-3010;;</fullResult> <status>FAILED</status> </log> <log logid="83efeae5190811100802450960"> <category>Upstream.CAI</category> <operation>Delete</operation> <target>EDSUB</target> <instance></instance> <user>server1</user> <context>sog</context> <fullOperation>DELETE:EDSUB:CODE,432350114484630:MDN,989352375449:PRE,0 EST,ALL;</fullOperation><starttime>20081110080245.012208</starttime> <stoptime>20081110080245.857994</stoptime> <fullResult>RESP:0;</fullResult> <status>SUCCESSFUL</status> </log> <log logid="83efeae5190811100802510961"> <category>Upstream.CAI</category> <operation>Create</operation> <target>EDSUB</target> <instance></instance> <user>server1</user> <context>sog</context> <fullOperation>CREATE:EDSUB:CODE,432350114484630:KI,1C9B39AAF3931D60C064F6E8FBB5B1E6:MDN,98935237544 9:PRE,0 EST,ALL;</fullOperation><starttime>20081110080251.089898</starttime> <stoptime>20081110080251.489396</stoptime> <fullResult>RESP:911364896;</fullResult> <status>FAILED</status> </log> <log logid="83efeae5190811100802540962"> <category>Upstream.CAI</category> <operation>Get</operation> <target>ESUB</target> <instance>CODE=432350114484630</instance> <user>server1</user> <context>sog</context> <fullOperation>GET:ESUB:CODE,432350114484630;</fullOperation> <starttime>20081110080254.000313</starttime> <stoptime>20081110080254.697545</stoptime> <fullResult>RESP:0:MDN,989352375449:CODE,432350114484630:T11,1:T21,1:T22,1:B16,1:T62,1:BAIC,0:BAOC,0 :BOIC,0:BIRO,0:BORO,0:BOIH,0:BOS4,0:CLIP,1:CLIR,0:CFB,1:CFNR,1:CFNA,1:CFU,1:HOLD,1:CW,1:MPTY,1:BAICS ,0,0:BAOCS,0,0:BOICS,0,0:PRE,0;</fullResult> <status>SUCCESSFUL</status> </log> <log logid="83efeae5190811100802570963"> <category>Upstream.CAI</category> <operation>Set</operation> <target>DSUB</target> <instance></instance> <user>server1</user> <context>sog</context> <fullOperation>SET SUB:MDN,989352375449;</fullOperation><starttime>20081110080257.888204</starttime> <stoptime>20081110080257.999121</stoptime> <fullResult>RESP:911265678;</fullResult> <status>FAILED</status> </log> </LogItems> |
|
||||
|
below commands I run. But not getting the proper output. However, it takes 3 minutes for 35MB file. But i have 900MB file
![]() egrep '<fullOperation>DELETE|<fullOperation>SET|<fullOperation>CREATE|<fullOperation>GET|<fullResult>RESP ' Ouput was- <fullOperation>GET:ESUB:MDN,989371072136;</fullOperation> <fullResult>RESP:0:MDN,989371072136:CODE,432350022011344:LASTNAME,989371072136:FIRSTNAME,2008-11-08_16_10:COUNTRY,IR:LANG,fa:PRE,1:SUBNAME,Eserve:MMS,0;</fullResult> <fullResult>RESP:0;</fullResult> <fullResult>RESP:0;</fullResult> --> Resp: comes twice Output should be- GET Resp:0 |
|
||||
|
Oaoo Greate its working. I want to put the Output in the files.
i ran it like below. But output.txt contains few string which is not matched with original output in my screen perl -nle'BEGIN {$/="</log>";$,="\n";$\="\n\n"} print /<fullOperation>(.*?):.*<fullResult>(.*?:.*?)[:;]/s' 2008-11-11.0.log > output.txt |
|
||||
|
Opss i really sorry buddy.. It worked. In fact i put the wrong filename.
Anyway, i hope i can put 'N' number of filenames with the perl script. perl -nle'BEGIN {$/="</log>";$,="\n";$\="\n\n"} print /<fullOperation>(.*?):.*<fullResult>(.*?:.*?)[:;]/s' logfile1 logflie2...logfileN |