can't parse this nawk statement


 
Thread Tools Search this Thread
Operating Systems AIX can't parse this nawk statement
# 1  
Old 06-03-2010
can't parse this nawk statement

hi all

i have the following portion in an xml file:

Code:
</n:AOMessage>
<?xml version="1.0" encoding="UTF-8"?>
<n:AOMessage xmlns:n="urn:ao:hs:update:shell" xmlns:bo="urn:ao:hs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ao:hs:update:shell http://staging.aoschema.ai2.cio.gto....l.hsupdate.xsd" aoXML.SchemaVersion="1.0">
  <aoXML.BusinessHdr>
    <aoXML.BusinessObjectType>HSUPDATE/INIT</aoXML.BusinessObjectType>
    <aoXML.BusinessObjectOwner>CDNA</aoXML.BusinessObjectOwner>
    <aoXML.BusinessObjectId>ldap:2369586</aoXML.BusinessObjectId>
    <aoXML.BusinessObjectVersion>0</aoXML.BusinessObjectVersion>
    <aoXML.BusinessEventTimeStamp>2010-04-22T17:22:54Z</aoXML.BusinessEventTimeStamp>
    <aoXML.BusinessObjectEventType>NEW</aoXML.BusinessObjectEventType>
    <aoXML.SchemaVersion>1.0</aoXML.SchemaVersion>
  </aoXML.BusinessHdr>
  <HSUpdate status="COMPLETED" type="INIT">
    <OrderIdentity domain="CDNA">1426423-1</OrderIdentity>
    <Timestamp>2010-04-22T17:22:55Z</Timestamp>
    <Value xsi:type="bo:LDAPValueType">
      <AoDirId>2369586</AoDirId>
      <Email>adrianne.lois@ao.com</Email>
      <NotesID>HSLOIS</NotesID>
      <Comments />
    </Value>
  </HSUpdate>
</n:AOMessage>

..which was nawk'd by a one liner command:

Code:
nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=13 a=9 s="`echo ${u}" $PSHOME/ai2/aoadapter-3.16/logs/AOAdapter_PeopleSoft.xml*

can someone help me analyze / break down each part in a way that's more understandable? i'm not a programmer but would love to know more about unix scripting

thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nawk Problem - nawk out of space in tostring on

Hi.. i am running nawk scripts on solaris system to get records of file1 not in file2 and find duplicate records in a while with the following scripts -compare nawk 'NR==FNR{a++;next;} !a {print"line"FNR $0}' file1 file2duplicate - nawk '{a++}END{for(i in a){if(a-1)print i,a}}' file1in the middle... (12 Replies)
Discussion started by: Abhiraj Singh
12 Replies

2. Shell Programming and Scripting

Parse SQL text and only format first SELECT statement.

Hi Forum. Need your expertise on the following question. I have the following file which I would like to parse, find first block of SELECT statment and concatenate all input fields as 1 field (~ delimited): Old File: SELECT /*+ USE_HASH(CCOMM ICAR IMAP IAS IP IMAS IMPS IAP SPCA) */ ... (5 Replies)
Discussion started by: pchang
5 Replies

3. Shell Programming and Scripting

Help nawk parse file

Hello, Hope you are doing fine. I have a file in following format. I only want to process the data inside the section that comes after #DATE,CODE,VALUE #ITEMS WITH CORRECTIONS ....... #DATE,CODE,VALUE 2011-08-02, ID1, 0.30 2011-08-02, ID2, 0.40 2011-08-02, ID3, 0.50 ...... Means... (3 Replies)
Discussion started by: srattani
3 Replies

4. Shell Programming and Scripting

ksh/nawk help with if statement to choose between 2 files

Hi! I am having a bit of a problem with my script. There are two different date formats that may appear in a file, either Jul-12 or Jul--6. I tried to create an if statement that searches for one of the formats and if that doesn't exist searches for the other, however it doesn't seem to be... (3 Replies)
Discussion started by: ther2000
3 Replies

5. Shell Programming and Scripting

Var in nawk script parse incorrectly

I'm writing a Texas Hold'em script in bash v3.00.16(1) to learn more about awk/nawk scripts and regex expressions by trying to randomize a list of names using awk's rand function. The problem is that the elements in the var convert to a single element in the nawk script. I've tried several things,... (4 Replies)
Discussion started by: HexKnot
4 Replies

6. Shell Programming and Scripting

Nesting - two nawk into one nawk

hi people; this is my two awk code: nawk '/cell+-/{r=(NF==8) ? $4FS$5FS$6 : NF==7 ? $4FS$5 : $4 ;c=split(r,rr);for (i=1;i<=c;i++){if(rr != "111111"){printf($3" %d ""\n",(i+3))}}printf("")}' /home/gc_sw/str.txt > /home/gc_sw/predwn.txt nawk -F'*' '{gsub(/ *$/,"")}$0=$1$($NF-2)'... (2 Replies)
Discussion started by: gc_sw
2 Replies

7. Shell Programming and Scripting

how to parse the file in xml format using awk/nawk

Hi All, I have an xml file with the below format. <a>111</a><b>222</b><c>333<c><d><e>123</e><f>234</f><d><e>456</e><f>789</f> output needed is 111,222,333,123,234 111,222,333,456,789 nawk 'BEGIN{FS="<|>"} {print a,b,c,e,f a="" ... (7 Replies)
Discussion started by: natalie23
7 Replies

8. Shell Programming and Scripting

nawk: illegal statement at source line 1

Hello Everyone, I don't know what is wrong with this: Is it that nawk cannot run a ".sh" script or is it not treating "." as a literal. If so how to make "." be treated as a literal in "nawk" statemnts? Thanks in Advance (2 Replies)
Discussion started by: bhaire
2 Replies

9. Shell Programming and Scripting

how to access values of awk/nawk variables outside the awk/nawk block?

i'm new to shell scripting and have a problem please help me in the script i have a nawk block which has a variable count nawk{ . . . count=count+1 print count } now i want to access the value of the count variable outside the awk block,like.. s=`expr count / m` (m is... (5 Replies)
Discussion started by: saniya
5 Replies

10. Shell Programming and Scripting

I can't seem to pass variables properly into a nawk statement

Ok, So up front I'm going to say that I'm a very elementary scripter, and I tend to use tools I don't fully understand, but I shotgun at something until I can get it to work...that said, I can't for the life of me understand why I can't get this to go down the way I want it to. The goal: -to... (6 Replies)
Discussion started by: DeCoTwc
6 Replies
Login or Register to Ask a Question