![]() |
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 |
| logfile | naveeng.81 | Shell Programming and Scripting | 1 | 04-07-2008 11:32 AM |
| Logfile Size exceeded ???? | skyineyes | Shell Programming and Scripting | 3 | 01-18-2008 08:51 AM |
| last month's logfile | deep_kol | Shell Programming and Scripting | 2 | 06-26-2007 02:27 PM |
| Extracting Logfile Entries | harpdl | Shell Programming and Scripting | 2 | 07-13-2006 01:40 PM |
| sort a logfile | joerg | Shell Programming and Scripting | 7 | 06-23-2004 01:28 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Code:
> cat file103 | sed "s/<\/session/~&/g" | tr "~" "\n" then grep for the lines you want to see? [Sorry I couldn't test, but your sample data did not have the appropriate tags or session markers for me to truly analyze.] |
|
|||||
|
Here is an actual snip from the log:
Code:
<SUMMARY filecount_excluded="0" dirbytes_sent="3367893" dirbytes_hashcache="13275664"><session numthreads="1" type="avtarbackup" ndispatchers="1"><host numprocs="4" speed="900" osuser="root" name="ashsux01" memory="24545" /> <build time="11:04:53" msgversion="13-10" appname="avtar"/><dirstats numfiles="193129" numbytes="1461473417216" numdirs="0" /></session><errorsummary exitcode="0" errors="0" warnings="0" fatals="0" /></SUMMARY> like this: Code:
<SUMMARY VARS...> <SESSION VARS...> <BUILD VARS.../> <DIRSTATS VARS.../> </SESSION> <ERRORSUMMARY VARS...\> </SUMMARY> Last edited by Ikon; 12-11-2008 at 05:52 PM.. |
|
|||||
|
then i think you have to do it with two or more awk
i tried some thing but not getting right hope you work more on it Code:
awk '/^<SUMMARY/{print $0}' file|awk -F"[=_]" 'BEGIN{RS=" "}$0!="<SUMMARY"{print "SUMMARY_"$1"="$3}'
Code:
awk '/^<session/{print $0}' file|awk -F"[= ]" 'BEGIN{RS=" "}$0!="<session"{print "SUMMARY_session_"$1"="$2}'
|
|
|||||
|
Well I decided to write it in perl...
Im having some problems: If you compair the log with the output its skipping the first item, ie CUSTOMER_join, ADDRESS_street, TODAY_date..... This is not the actual log file it will be reading it just a quick on I put together. The actual log if faily large. Code:
# cat testfile.log <CUSTOMER join="1/1/2008" last="12/20/2008"> <NAME name="John" lname="Smith"> <ADDRESS street="main" number="123" city="Orlando" state="Florida" zip="12345" /> </DATA> </CUSTOMER> <TODAY date="12/11/2008" time="12:12:12" /> Code:
# perl readlog.pl testfile.log CUSTOMER_last: 12/20/2008 NAME_lname: Smith ADDRESS_number: 123 ADDRESS_city: Orlando ADDRESS_state: Florida ADDRESS_zip: 12345 TODAY_time: 12:12:12 Code:
# cat readlog.pl
$filename = $ARGV[0];
open FILE, $filename or die $!;
while (<FILE>) {
push(@fields, defined($1) ? $1:$3)
while m/([^<>]+)/g;
}
close(FILE);
$head="";
foreach (@fields) {
if ($_ =~ /^([A-Za-z0-9]+) /) {
$line = $_;
($header,$data) = split(/ /, $line, 2);
if ( $head == "" ) {
$head = $header;
} else {
$head = $head."_".$header;
}
@subs = split(/" /,$data);
for($i = 0; $i < @subs; $i++) {
($str, $strdata) = split (/=/,$subs[$i]);
$strdata =~ s/^"//;
$strdata =~ s/"$//;
$head =~ s/_{2,}/_/;
if ($str !~ /\//) {
print $head."_".$str.": ".$strdata."\n";
}
}
if ($data =~ /\/$/) {
@h = split(/_/,$head);
$max = @h - 1;
$head =~ s/$h[$max]// ;
}
} else {
if ($_ =~ /^\//) {
@h = split(/_/,$head);
$max = @h - 1;
$head =~ s/$h[$max]// ;
}
}
}
Last edited by Ikon; 12-11-2008 at 05:51 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|