![]() |
|
|
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 08:30 AM |
| egrep/grep result of more files | tvrman | Shell Programming and Scripting | 3 | 08-07-2008 09: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 |
|
|
|
||||
|
Its working. great.
Could you please help me to get the script how do it calculate like below from the outputfile- How many CREATE with RESP:3* How many CREATE with RESP:9* How many CREATE with RESP:9??3????? How many CREATE with RESP:9??3???96 CREATE RESP:3010 CREATE RESP:911364896 DELETE RESP:0 SET RESP:911265678 |
|
||||
|
Oaaaao........its really great. I expecting the output in this way.
![]() I need to add the SET, DELETE logic with the below CREATE. Example- How many SET with RESP:3* How many SET with RESP:9* How many SET with RESP:9??3????? How many SET with RESP:9??3???96 May i define the script like below- perl -nle' BEGIN { $/ = "</log>"; $, = "\n"; $\ = "\n\n" } print /<fullOperation>(.*?):.*<fullResult>(.*?:.*?)[:;]/s; if ($1 eq "CREATE") { $r = (split /:/, $2)[1]; $r =~ /^3/ and $r3++; $r =~ /^9/ and $r9++; $r =~ /9\d{2}3\d{5}/ and $r93++; $r =~ /9\d{2}3\d{3}96/ and $r9396++; } if ($1 eq "SET") { $r = (split /:/, $2)[1]; $r =~ /^3/ and $r3++; $r =~ /^9/ and $r9++; $r =~ /9\d{2}3\d{5}/ and $r93++; $r =~ /9\d{2}3\d{3}96/ and $r9396++; } END { printf "CREATE 3* : %d\nCREATE9* : %d\nCREATE9??3????? : %d\nCREATE9??3???96 : %d\n", $r3, $r9, $r93, $r9396; printf "SET3* : %d\nSET9* : %d\nSET9??3????? : %d\nSET9??3???96 : %d\n", $r3, $r9, $r93, $r9396; }' infile |
|
|||||
|
Well, you'll need more code ![]() Try something like this (some declarations may need to be adjusted): Code:
perl -wnle'
BEGIN {
$/ = "</log>";
our %pats = qw/3* 3 9* 9 9??3????? 9\d{2}3\d{5} 9??3???96 9\d{2}3\d{3}96/;
}
our ($r, $op, $res, $in);
if (($op, $r) = /<fullOperation>(.*?):.*<fullResult>(.*?:.*?)[:;]/s) {
printf "%s\n%s\n\n", $op, $r;
$res = (split /:/, $r)[1];
for (keys %pats) {
$ops{$op}{$_}++ if $res =~ /^$pats{$_}/;
}
}
END {
$, = " ";
print "-" x 20;
while (my ($k, $v) = each %ops) {
printf $k, ": ";
while (my ($k, $v) = each %$v) {
print "\t$k : $v\n";
}
}
}' infile
Last edited by radoulov; 11-17-2008 at 04:31 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|