Sponsored Content
Full Discussion: Explain this AWK script plz
Top Forums Shell Programming and Scripting Explain this AWK script plz Post 302340405 by Gopal_Engg on Monday 3rd of August 2009 10:17:27 AM
Old 08-03-2009
Quote:
Originally Posted by aigles
Code:
awk -v Outfile=ora.txt '
. . .
' ora.log

Execute awk script for the input file ora.log.
The variable Outfile is initialized, before executing the awk script, with the output file name

Code:
/^ORA-/ {
   split($0, f, "\"");
   Target_schema = f[2];
   Target_table = f[4];
   Ora_error = $0;
}

Records starting with 'ORA-' are selected..
The Oracle error text is memorized in the variable Ora_error

Code:
/Targ Rowid=/ { 
   Rejected_count++ ;
   Get_detail++;
   printf "#%d => %s\n", Rejected_count, Ora_error;
   next;
}

Records containing 'Targ RowId=' are selected.
The number of rejected records found is incremented (variable Rejected_count).
The following records will contain the columns details ending with the ')' record.
The variable Get_detail, which is set to TRUE (value 1),indicates that we are now reading for columns details.

Code:
/^)/ && Get_detail {
   print Rejected_count,Values_detail > Outfile; 
   Values_detail = "";
   Get_detail = 0;
   next;
}

Records starting with ')'' are selected if we are reading columns details.
There is no more columns details records for this rejected record, so the memorized values of columns are writen in the output file.
The variable Get_detailis set to FALSE (value 1),

Code:
Get_detail {
   sub(/\(.*\):/,"=");
   Values_detail = Values_detail $0 "|"
}

Records are selected if we are reading columns details.
The value of the column is memorized in the [/i]Values_detail[/i] variable.

Code:
END {
   print "Total Lines in Session Log",FILENAME,"is :",NR;
   print "Total Nr of Rejected Records Captured in Sesslog is :",Rejected_count;
}

Display statistics at end of file.


My apologies for my poor English.
Jean-Pierre.
Hi Thanks for you reply
but tell me what you mean by "column details"?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Explain awk

Hi, I found this command in this forum, but, couldnt understand much from it. could any one help me understand that??? the commands are : awk '{sub(/ ~/,""); printf $0 ($0~/\|$/?ORS:"")}' file1 > file2 awk '{sub(/~ */,x);printf $0(/\|$/?ORS:x)}' awk '{sub(/~ */,x);sub(/\|$/, "|\n")}8'... (4 Replies)
Discussion started by: hitmansilentass
4 Replies

2. UNIX for Advanced & Expert Users

Can anyone explain plz

HI, Can anyone explain to me how does the following command work - > current_dir=`cd \`/usr/bin/dirname $0\` && pwd` Regards, Ranga (3 Replies)
Discussion started by: r_W213
3 Replies

3. UNIX for Dummies Questions & Answers

explain command plz

echo -n "1. Updating Password Policy in OID..." | tee -a $logfile set ldap_v1 = `ldapsearch -b "" -h $oid_host -p $oid_port -D "cn=orcladmin" -w $admin_pwd -s sub "cn=PwdPolicyEntry" dn | head -1` echo "dn:$ldap_v1" > ldap1.out echo "changetype:modify" >> ldap1.out echo... (2 Replies)
Discussion started by: maoro
2 Replies

4. Shell Programming and Scripting

help in writing awk script, plz urgent

I have a file like this I have to I have input file this , I want to give the out put in the below input file (NARAYANA 1 ENDING AT (100, 16383) ,NARAYANA 2 ENDING AT (100, 32766) ,NARAYANA 3 ENDING AT (100, 49149) ,NARAYANA 4 ENDING AT (100, 65535) ,NARAYANA 5... (8 Replies)
Discussion started by: LAKSHMI NARAYAN
8 Replies

5. Shell Programming and Scripting

plz help in writing awk script

hi buddies pls help in this matter i have file like this input file -------------------------- (PARTITION PARTITION_1 VALUES LESS THAN (101, 16383 ) TABLESPACE PART_1 ,PARTITION PARTITION_2 VALUES LESS THAN (101, 32766 ) TABLESPACE PART_2 ,PARTITION PARTITION_3 VALUES LESS THAN (101,... (3 Replies)
Discussion started by: LAKSHMI NARAYAN
3 Replies

6. Shell Programming and Scripting

perl doubt plz explain....

hi all i wrote a shell script which uses perl script my code is : >cat filename | while read i >do >perl -e 'require "/home/scripts/abc.pl" ; abc("$i")' >done perl script used will simply check syntax of Cobol programs but it didn't work for me so i asked my colleague he suggested... (1 Reply)
Discussion started by: zedex
1 Replies

7. Shell Programming and Scripting

explain plz

can u explain this step by step........plz...will it do the same for I in *.tar.gz; do A=`basename $I .tar.gz` mkdir $A cp marking-guide ${A}/$A cd $A gunzip -c ../$I | tar xf - cd.. done thnx __________________ (2 Replies)
Discussion started by: avikal
2 Replies

8. Shell Programming and Scripting

plz explain the execution flow

CODE file=/tmp/rap54ibs2sap.txt trap "rm $file; exit" 0 1 2 3 15 trap rm $file execution result trap -- 'rm /tmp/rap54ibs2sap.txt; exit' EXIT trap -- 'rm /tmp/rap54ibs2sap.txt; exit' SIGHUP trap -- 'rm /tmp/rap54ibs2sap.txt; exit' SIGINT trap -- 'rm /tmp/rap54ibs2sap.txt;... (1 Reply)
Discussion started by: rrd1986
1 Replies

9. Shell Programming and Scripting

Plz explain the process of this code....

Hi Unix Gurus, Please explain the processing done by the code mentioned below: for (i=1;i<=59;i++) { sub(/ *$/,"", $i) } newrec_key = $2 new_line = $0 if (empty_oldfile==1) { #newly added record ++num_add print "Added key: ", newrec_key > LogFile #print out... (4 Replies)
Discussion started by: ustechie
4 Replies

10. Shell Programming and Scripting

Explain this awk

found this handy one liner in another thread which is closed, it does what i need but im trying to understand it. it basically matches the field that contains the value v and prints its position awk -F, '{for(i=1;i<=NF;i++)if($i==v)print i}' v=yourfield inputfile my understanding is assign... (3 Replies)
Discussion started by: jack.bauer
3 Replies
All times are GMT -4. The time now is 11:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy