Unix/Linux gurus...here is Q 4u


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix/Linux gurus...here is Q 4u
# 1  
Old 02-13-2009
Unix/Linux gurus...here is Q 4u

Suppose I have two files 1.txt and 2.txt.
My aim is to find (Total execution time/Number of executions)
then sort the result as in decreasing order.
Can anyone provide me any shell/perl/awk script or a Command to do that in faster way ?

1.txt :
===============================
Number of executions = 738
Number of executions = 23
Number of executions = 11383
Number of executions = 234
===============================

2.txt :
===============================
Total execution time = 8.9823
Total execution time = 823
Total execution time = 9837
Total execution time = 8.9823
===============================
# 2  
Old 02-13-2009
Code:
sort -t= -nrk2,2 1.txt

Sorry, didn't read full question...

Last edited by krishmaths; 02-13-2009 at 01:30 AM.. Reason: Incorrect solution
# 3  
Old 02-13-2009
@krishmaths

sort -t= -nrk2,2 1.txt
...will only sort the 1.txt file.....


Basically I want to do (Total execution time/Number of executions) line by line from both files....
eg
===================
8.9823/738 = 0.012
823/23 = 35.782
9837/11383 = 0.864
8.9823/234 = 0.038
===================

then sort the above result...
===================
823/23 = 35.782
9837/11383 = 0.864
8.9823/234 = 0.038
8.9823/738 = 0.012
===================

I want to also know in the output that for which "Total execution time" and "Number of executions" we are getting what results....like I pasted the above result.

Example......in above eg I can see the max is 35.782 for "Total execution time" = 823 and "Number of executions" = 23.
# 4  
Old 02-13-2009
Code:
paste 1.txt 2.txt |
awk '{ printf "%s/%s = %3.3f\n", $10, $5, $10/$5}' |
sort -r -k3

# 5  
Old 02-13-2009
@fpmurphy

Thanks fpmurphy !

I get the desired output but you can see the error/message in RED.
Is it safe to ignore all 3 lines? I want to make sure because for my project we have hell lots of lines in the input files and a single mistake in division or missing any line will mess our project.


$ paste 1.txt 2.txt | awk '{ printf "%s/%s = %3.3f\n", $10, $5, $10/$5}' | sort -r -k3
awk: 0602-566 Cannot divide by zero.
The input line number is 5.
The source line number is 1.
823/23 = 35.783
9837/11383 = 0.864
8.9823/234 = 0.038
8.9823/738 = 0.012
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Question to gurus with expect

Hi., I need to ask question for expect script. I have prompt like # and very long script (orachk). I added to expect script line set prompt "(%|#|\\\$) $" and insert into it also piece of code ---- expect { timeout { puts "Running..." exp_continue } ... (0 Replies)
Discussion started by: beckss
0 Replies

2. Shell Programming and Scripting

Question to gurus about sed.

Hi Folks. I need change something into file and after all manipulation I need delete only last COMMA into this piece of code -> GROUP 1 ( '/oralog1/ORAPRD/log01a.dbf', '/oralog2/ORAPRD/log01b.dbf' ) SIZE 512M, GROUP 2 ( '/oralog1/ORAPRD/log02a.dbf', ... (12 Replies)
Discussion started by: beckss
12 Replies

3. UNIX for Dummies Questions & Answers

Calling all the awk gurus out there.

Hi all, I just signed up to the forums, although, I have lurked on here for awhile. Anyways, my issue is I am trying to get awk to spit out something I can use without having to spend hours in excel hell haha. So, I used sed to replace the spaces with semicolons and redirected that to a file. ... (6 Replies)
Discussion started by: savigabi
6 Replies

4. Shell Programming and Scripting

Need Urgent Help from UNIX gurus to get specific data from a file

Hi, I have a file monitor.txt as below... # Times are converted to local time from GMT. # Local Timezone: EST (GMT -05:00) PARAM1 { TIME 30; CC1 "xxxxx"; CC2 "xxxxx"; CC3 "xxxxx"; CC4 "xxxxx"; } PARAM2 { 4061 :... (3 Replies)
Discussion started by: zaq1xsw2
3 Replies

5. Shell Programming and Scripting

Unix gurus : how to grep this pattern?

Hello Unix gurus, My log file has entries in below format : ================================================================= 2009-01-19-01.19.24.816169+660 I8635A1158 LEVEL: Error PID : 5873782 TID : 1 PROC : aaaa APPHDL : 0-269 AUTHID : PDBCMPC... (12 Replies)
Discussion started by: Rahulpict
12 Replies

6. Shell Programming and Scripting

VI Editor - question for unix gurus !!

I have created a dummy file -demo.txt On my machine-A (oslevel-5300-08) I can display the file content in HEX format through VI editor using :%!xxd but on other machine-B (oslevel - 5300-06) , I get error as "sh: xxd: not found." machine-A: $ cat demo.txt Hello World ! I can display... (7 Replies)
Discussion started by: Rahulpict
7 Replies

7. Shell Programming and Scripting

Hey Perl Gurus

Hey guys im trying to get this if statement to work and i dont know whats wrong. can anybody help? if($author=~/\A+\Z/i)&&(length($author!=0)) { print " $author validation correct" } elsif($author!=~/\A+\Z/i)&&(length($author=0)) { $author='BLANK'; } else { ... (1 Reply)
Discussion started by: neil1983
1 Replies

8. Shell Programming and Scripting

SED GURUS - Help!

I wish to substituite a string on each line but ONLY if it appears within double-quotes: this_string="abc#def#geh" # Comment here I wish to change the "#" characters within the double quoted string to "_": this_string="abc_def_geh" # Comment here ... but as you see, the "comment" hash... (2 Replies)
Discussion started by: Simerian
2 Replies

9. Shell Programming and Scripting

Help with shell script - Unix Gurus calling

Unix Gurus, I have been breaking my head to get this done..seems simple.. I need to read a flat file and based on a key word in a line, i need to skip the previous 3 lines. eg : Line1 Line2 Line3 Line4 Line5 Line6 Error Line7 Line8 Line9 Error Line10 (4 Replies)
Discussion started by: ravred
4 Replies

10. UNIX for Advanced & Expert Users

Any RF unix gurus out there?

I am having a problem here. We are having several problems in regards to hung process's on unix (HPUX box), caused by my RF equipment (Mobile data capture units). these contact the host via a simply telnet session and locks the system? Is it a timeout problem as the timeout is disabled on the host. (5 Replies)
Discussion started by: Subrosa
5 Replies
Login or Register to Ask a Question