write a script for this pattern...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting write a script for this pattern...
# 8  
Old 06-12-2009
Quote:
Originally Posted by Rahulpict
Thanks vidyadhar85 for details.

Now im getting good results but...there is something diff from your results...check the 1st row. It has NaNQ.

$ $3+($5/1000000000))/$1,$NF}}' perf |sort -r -k1 | more <
NaNQ xjjv
0.351779 efgh
0.298643 lppeuv
0.035063 lldff
0.011686 hijk
0.001250 jhd
0.000268 abcd
0.000183 nnuua
0.000077 sahjdi
0.000038 asadj
0.000019 oet
0.000013 hjass
0.000004 dfhjf
0.000001 sjhfdf
0.000001 sfowe
0.000001 dkfi
0.000000 posdio
0.000000 lmhn


When I use this script for different input file which has similar format/pattern....I get all 1st column values as NaNQ.
Please let me know where is the problem.
Thats because the row containing NaNQ is missing a "(" after no of execution
Quote:
3 (0 sec, 804275 nanosec) abcd
721 (253 sec, 632655866 nanosec) efgh
1873 (21 sec, 887264375 nanosec) hijk
2006 (0 sec, 922300 nanosec) lmhn
3 (0 sec, 3332 nanosec) sjhfdf
2 (0 sec, 2367 nanosec) dkfi
580 (0 sec, 2138703 nanosec) dfhjf
44486 (0 sec, 858447770 nanosec) oet
21102 (739 sec, 891470054 nanosec) lldff
140 (0 sec, 90282 nanosec) sfowe
123 0 sec, 324590 nanosec) xjjv
8939 (0 sec, 337230856 nanosec) asadj
19 (0 sec, 1455434 nanosec) sahjdi
210 (0 sec, 89131 nanosec) posdio
3 (0 sec, 3750149 nanosec) jhd
873 (260 sec, 715043557 nanosec) lppeuv
16 (0 sec, 212024 nanosec) hjass
13668 (2 sec, 506391927 nanosec) nnuua
# 9  
Old 06-13-2009
Thanks vidyadhar85 I got that meaning now.
But, still the script dont work for other input files....plz see this input file...

Code:
$ cat test.txt
192     (324 sec, 747387967 nanosec)     sqljsParse
194     (324 sec, 742760541 nanosec)     sqljsParseRdbAccessed
507     (283 sec, 660176478 nanosec)     sqlkf_sync_request
273     (269 sec, 673915252 nanosec)     sqlkdInterrupt
39      (269 sec, 337740235 nanosec)     sqlrkcmt
39      (269 sec, 654343714 nanosec)     sqlrrcom_dps
39      (269 sec, 666073125 nanosec)     sqlrrcom
39      (269 sec, 698604620 nanosec)     sqlrr_commit
39      (269 sec, 698958957 nanosec)     sqljs_ddm_rdbcmm
78      (269 sec, 583300457 nanosec)     sqlrr2pd
417     (37 sec, 834469926 nanosec)      sqlra_cache_space_mgmt
417     (37 sec, 846534878 nanosec)      sqlra_cache_reserve_mem
597     (31 sec, 705247032 nanosec)      sqlo_xlatch::getConflict
417     (30 sec, 633582480 nanosec)      sqlra_csm_flush_vars
39      (27 sec, 660368820 nanosec)      sqlrr_execimmd
39      (27 sec, 674433628 nanosec)      sqljs_ddm_excsqlimm
75      (19 sec, 155225907 nanosec)      sqlra_find_var
75      (19 sec, 190364402 nanosec)      sqlra_get_var
39      (16 sec, 305720732 nanosec)      sqlrr_execute_immed
117     (14 sec, 151555035 nanosec)      sqlrices
117     (14 sec, 177620542 nanosec)      sqlriCloseExecuteSection
117     (14 sec, 54696517 nanosec)       sqlrigca
156     (14 sec, 126475719 nanosec)      sqleReceiveAndMergeReplies
234     (14 sec, 513398100 nanosec)      sqloWaitEDUWaitPost
234     (14 sec, 526877995 nanosec)      sqlkf_get_next_buffer
234     (14 sec, 527734589 nanosec)      sqkd_bds_buffer_table::getNextBuffer
234     (14 sec, 528675358 nanosec)      sqlkd_rcv_buffer
234     (14 sec, 529943418 nanosec)      sqlkd_rcv_get_next_buffer
234     (14 sec, 530817210 nanosec)      sqlkd_rcv_init
234     (14 sec, 545068593 nanosec)      sqlkdReceiveReply
35      (14 sec, 825808972 nanosec)      sqlrr_prepare
35      (14 sec, 830216291 nanosec)      sqljs_ddm_prpsqlstt
154     (12 sec, 142066439 nanosec)      sqlragsn
194     (12 sec, 340492976 nanosec)      sqlrr_sql_request_pre

--------------<end of input file>------------------


awk -F"[( ]" '{if ($1=="0"){print "0.000000 "$NF}else{printf "%f %s\n",($3+($5/1000000000))/$1,$NF}}' test.txt |sort -r -k1 | more
0.000000 sqlrrcom_dps
0.000000 sqlrrcom
0.000000 sqlrr_sql_request_pre
0.000000 sqlrr_prepare
0.000000 sqlrr_execute_immed
0.000000 sqlrr_execimmd
0.000000 sqlrr_commit
0.000000 sqlrr2pd
0.000000 sqlrkcmt
0.000000 sqlrigca
0.000000 sqlrices
0.000000 sqlriCloseExecuteSection
0.000000 sqlragsn
0.000000 sqlra_get_var
0.000000 sqlra_find_var
0.000000 sqlra_csm_flush_vars
0.000000 sqlra_cache_space_mgmt
0.000000 sqlra_cache_reserve_mem
0.000000 sqlo_xlatch::getConflict
0.000000 sqloWaitEDUWaitPost
0.000000 sqlkf_sync_request
0.000000 sqlkf_get_next_buffer
0.000000 sqlkd_rcv_init
0.000000 sqlkd_rcv_get_next_buffer
0.000000 sqlkd_rcv_buffer
0.000000 sqlkdReceiveReply
0.000000 sqlkdInterrupt
0.000000 sqljs_ddm_rdbcmm
0.000000 sqljs_ddm_prpsqlstt
0.000000 sqljs_ddm_excsqlimm
0.000000 sqljsParseRdbAccessed
0.000000 sqljsParse
0.000000 sqleReceiveAndMergeReplies
Standard input

Last edited by Yogesh Sawant; 06-28-2009 at 05:05 AM.. Reason: added code tags
# 10  
Old 06-15-2009
can anyone fix this?
# 11  
Old 06-15-2009
With your script and input, I am getting this result...I have not done anything to get different o/p... Are you sure, you are running it properly.
Code:
6.915358 sqljs_ddm_rdbcmm
6.915349 sqlrr_commit
6.914515 sqlrrcom
6.914214 sqlrrcom_dps
6.906096 sqlrkcmt
3.456196 sqlrr2pd
1.691393 sqljsParse
1.673932 sqljsParseRdbAccessed
0.987817 sqlkdInterrupt
0.709601 sqljs_ddm_excsqlimm
0.709240 sqlrr_execimmd
0.559488 sqlkf_sync_request
0.423720 sqljs_ddm_prpsqlstt
0.423595 sqlrr_prepare
0.418095 sqlrr_execute_immed
0.255872 sqlra_get_var
0.255403 sqlra_find_var
0.121176 sqlriCloseExecuteSection
0.120953 sqlrices
0.120126 sqlrigca
0.090759 sqlra_cache_reserve_mem
0.090730 sqlra_cache_space_mgmt
0.090554 sqleReceiveAndMergeReplies
0.078845 sqlragsn
0.073462 sqlra_csm_flush_vars
0.063611 sqlrr_sql_request_pre
0.062158 sqlkdReceiveReply
0.062098 sqlkd_rcv_init
0.062094 sqlkd_rcv_get_next_buffer
0.062088 sqlkd_rcv_buffer
0.062084 sqkd_bds_buffer_table::getNextBuffer
0.062081 sqlkf_get_next_buffer
0.062023 sqloWaitEDUWaitPost
0.053108 sqlo_xlatch::getConflict


Last edited by Yogesh Sawant; 06-28-2009 at 05:04 AM.. Reason: added code tags
# 12  
Old 06-15-2009
Quote:
Originally Posted by Rahulpict
can anyone fix this?
please attach your input file.. according to your present input that awk should work fine.. its giving correct o/p for me..
# 13  
Old 06-15-2009
I am still having a mystery here....
I have tested it on my side on LINUX and AIX but I get same results as I pasted in my earlier reply....this is really a strange issue....

My input file is...

Code:
$ cat test.txt
192     (324 sec, 747387967 nanosec)     sqljsParse
194     (324 sec, 742760541 nanosec)     sqljsParseRdbAccessed
507     (283 sec, 660176478 nanosec)     sqlkf_sync_request
273     (269 sec, 673915252 nanosec)     sqlkdInterrupt
39      (269 sec, 337740235 nanosec)     sqlrkcmt
39      (269 sec, 654343714 nanosec)     sqlrrcom_dps
39      (269 sec, 666073125 nanosec)     sqlrrcom
39      (269 sec, 698604620 nanosec)     sqlrr_commit
39      (269 sec, 698958957 nanosec)     sqljs_ddm_rdbcmm
78      (269 sec, 583300457 nanosec)     sqlrr2pd
417     (37 sec, 834469926 nanosec)      sqlra_cache_space_mgmt
417     (37 sec, 846534878 nanosec)      sqlra_cache_reserve_mem
597     (31 sec, 705247032 nanosec)      sqlo_xlatch::getConflict
417     (30 sec, 633582480 nanosec)      sqlra_csm_flush_vars
39      (27 sec, 660368820 nanosec)      sqlrr_execimmd
39      (27 sec, 674433628 nanosec)      sqljs_ddm_excsqlimm
75      (19 sec, 155225907 nanosec)      sqlra_find_var
75      (19 sec, 190364402 nanosec)      sqlra_get_var
39      (16 sec, 305720732 nanosec)      sqlrr_execute_immed
117     (14 sec, 151555035 nanosec)      sqlrices
117     (14 sec, 177620542 nanosec)      sqlriCloseExecuteSection
117     (14 sec, 54696517 nanosec)       sqlrigca
156     (14 sec, 126475719 nanosec)      sqleReceiveAndMergeReplies
234     (14 sec, 513398100 nanosec)      sqloWaitEDUWaitPost
234     (14 sec, 526877995 nanosec)      sqlkf_get_next_buffer
234     (14 sec, 527734589 nanosec)      sqkd_bds_buffer_table::getNextBuffer
234     (14 sec, 528675358 nanosec)      sqlkd_rcv_buffer
234     (14 sec, 529943418 nanosec)      sqlkd_rcv_get_next_buffer
234     (14 sec, 530817210 nanosec)      sqlkd_rcv_init
234     (14 sec, 545068593 nanosec)      sqlkdReceiveReply
35      (14 sec, 825808972 nanosec)      sqlrr_prepare
35      (14 sec, 830216291 nanosec)      sqljs_ddm_prpsqlstt
154     (12 sec, 142066439 nanosec)      sqlragsn
194     (12 sec, 340492976 nanosec)      sqlrr_sql_request_pre


Last edited by Yogesh Sawant; 06-28-2009 at 05:04 AM.. Reason: added code tags
# 14  
Old 06-15-2009
Code:
awk '
sub(/\(/,"",$2) && $2 != 0 && $1 != 0{
  print $2/$1 , $NF | "sort -rn" 
}' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk; pattern match, remove and re write

the following pattern match works correctly for me awk '/name="Fruits"/{f=1;next} /"name=Vegetables"/{f=0} f' filename This works well for me. Id like to temporarily move the match out of the file ( > newfile) and be able to stick it back in the same place at a later time. Is this... (7 Replies)
Discussion started by: TY718
7 Replies

2. Shell Programming and Scripting

Search pattern and write line into another file

Hi, I have a file which contains the below details.. My requirement is to fetch all the lines which are starting with "ABC_XY_" into 1 file and rest of the lines (not starting with "ABC_XY_") into another file. Could you please help with what command needs to be used? file1.txt ----------... (12 Replies)
Discussion started by: satyaatcgi
12 Replies

3. Shell Programming and Scripting

[Solved] Pattern match and write to separate files

I need to parse a file and depending on a patern match(in the insert job line) separate files have to be created with a line added (content in file2). Mapping for pattern match and add line : for Alpha 123 for Beta 234 for Gamma 345 no match (goes into another file) File 1 ... (3 Replies)
Discussion started by: w020637
3 Replies

4. Shell Programming and Scripting

Check for Pattern if exists write to file

Hi ! All I just want to search and write to new file if pattern is found in text file following are my text files by which I want to search Month and last column number my text file1 15-Jan-2011 25 ARTS 1255 125 125 178 198 15-Jan-2011 25 ARTS 1255 125 125 178 198 15-Jan-2011 25... (3 Replies)
Discussion started by: nex_asp
3 Replies

5. Shell Programming and Scripting

Script to compare pattern and print a different pattern in each line

Hi, I am writing a shell script to parse some files, and gather data. The data in the files is displayed as below. .......xyz: abz: ......qrt: .... .......xyz: abz: ......qrt: ... I have tried using awk and cut, but the position of these values keep changing, so I wasn't able to get... (2 Replies)
Discussion started by: Serena
2 Replies

6. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

7. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

8. Shell Programming and Scripting

grep a pattern and replace a value in it and write to the same file.

I have some complication with this, I have a file like below for DEV_1 till DEV_10. and the db values are set accordinly which are not unique. For example DEV1,DEV4,DEV6 can have the same target DB name. I waned to identify for DEV_2 and then replace the TARGET_DATABASE value with the new DB... (6 Replies)
Discussion started by: yesmani
6 Replies

9. Shell Programming and Scripting

To write a shell script which groups files with certain pattern, create a tar and zip

Hi Guru's, I have to write a shell script which groups file names based upon the certain matching string pattern, then creates the Tar file for that particular group of files and then zips the Tar file created for the respective group of files. For example, In the given directory these files... (3 Replies)
Discussion started by: rahu_sg
3 Replies

10. Shell Programming and Scripting

help needed .. Unable to write the data to new file after matching the pattern

Hi, i am pretty new to Unix environment ..... Can i get some help from any of you guyz on writing Unix script. my requirement is like reading a csv file, finding a specific pattern in the lines and repalce the string with new string and write it to another file. My file is file ABC123.dat... (3 Replies)
Discussion started by: prashant_jsw
3 Replies
Login or Register to Ask a Question