Location: India [Great India] hey hey .. urs also greaty country frnd
Posts: 60
Thanks Given: 0
Thanked 0 Times in 0 Posts
Explain this AWK script plz
Hi frnds,
one my frnds has given resolution for my problem as below. it working great , but i couldnt understand somethings in the script.
Why ++ operator after the function calling. how these each block working. will each run for each input line sequencially or one block for all the lines and next block execeted? plz clarify.
So, what is the problem u have to resolve ??? It's better to know the requirements (input/output) and the solution than just the solution, right ?
plz clarify ^__^
Location: India [Great India] hey hey .. urs also greaty country frnd
Posts: 60
Thanks Given: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by thanhdat
So, what is the problem u have to resolve ??? It's better to know the requirements (input/output) and the solution than just the solution, right ?
plz clarify ^__^
[Code
Hi thanhdat
Plz look into my actual posting and plz explan me the AWK script that one of our frnd given as a solution.Plzzz
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.
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),
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.
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),
Location: India [Great India] hey hey .. urs also greaty country frnd
Posts: 60
Thanks Given: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Gopal_Engg
Hi Thanks for you reply
but tell me what you mean by "column details"?
Code:
Hi frnd,My main problem is thatWe need to identify the keyword Targ Rowid= and “)” . Then we need to read the block of data (column values ) resides between those search pattern. Ok.And we hav to loop through the entire log file to pick all required column values. FineNow in ur script, you have onse function named “Get_detail” which replace unwanted data with = symbol and make the block of data into single line with | delimited. FineWhen ur calling the function , y hv you mention ++ symbol. (ie., Get_detail++) . whether it is calling the function or just a normal variable declaration. If its declaration whats the use of it. What is the use of next; how its helping us to fulfill our requirement here.?In the 3rd , we have like /^)/ && Get_detail { . whats the use of Get_detail here. Is it a function calling? If so how its working. And why get_detail=0;my main question is that,we want to identify the both seach pattern and get the block of data and the block of data with pipe delimited. And need to loop through the entire log file.You hv achived it in ur script. That is great. But I want understand how it capture the block of data .how this script loop through the session log for same purpose.Plz explin the control flow in the script( ie., when ,which line ll get executed ?) explain me line by line. Plz frnd plzz .. even I couldn't sleep well since I couldn't understand the script.Note: plz don't give overview explaination of the scriopt as you gave earlier. Plz little pit deeper. Line by line I want . I want control flow in the script.Plz dont ignor this post.Send me the explination to my mail id: gopal.narayanan@tcs.com
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)
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)
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)
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)
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)
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)