Script not working..."sort" not working properly....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script not working..."sort" not working properly....
# 8  
Old 03-14-2009
Perderabo,
I haven't changed any input.
Why I should do that? Rather I know you guys r helpful why I should delay my desired task ?

Also, as I said I have already uploaded the test input file....why dont you test the below 2 commands and see the difference by yourself?
I again run these 2 commands and still the same.....

Please use my test input and try at your end.....If your saying I changed the file Smilie ......you should see the difference by urself.....

And yeah, I completely agree with your statement...the divisors are getting different....but why? again thats my question to you expert guys....

cat 12.txt | awk '{ printf "%s/%s = %3.3f\n", $11, $5, $11/$5}' | sort -r -k3 | more
9.396545/1 = 9.397
9.039183/1 = 9.039
76.712522/10 = 7.671
6.857941/1 = 6.858
18.470404/3 = 6.157
4.516811/1 = 4.517
4.214784/1 = 4.215
4.043929/1 = 4.044
3.868609/1 = 3.869
3.442802/1 = 3.443
3.198656/1 = 3.199
41.095447/2 = 20.548
2.967361/1 = 2.967
11.660539/4 = 2.915
2.599642/1 = 2.600
7.414902/3 = 2.472
2.375463/1 = 2.375
4.402904/2 = 2.201
2.123307/1 = 2.123
47.139053/3 = 15.713
7.567567/4 = 1.892
1845.985563/1083 = 1.705
5.069130/3 = 1.690
.

cat 12.txt | awk '{ printf "%s/%s = %3.3f\n", $11, $5, $11/$5}' | sort -r -k3,3n | more

9.742084/395690 = 0.000
9.510659/75186 = 0.000
9.194549/39095 = 0.000
8.146552/39095 = 0.000
8.008833/16050 = 0.000
735.600018/1760004 = 0.000
7.364725/28144 = 0.000
65.096662/842315 = 0.000
6.923107/37595 = 0.000
6.922309/127260 = 0.000
6.210832/27525 = 0.000
6.061399/82765 = 0.000
53.091542/833311 = 0.000
5.345867/53453 = 0.000
5.098626/49097 = 0.000
48.261439/135377 = 0.000
46.527917/791108 = 0.000
4.794862/9664 = 0.000
4.644286/65200 = 0.000
4.552522/11571 = 0.000
4.508161/57871 = 0.000
4.039346/87768 = 0.000
4.023613/48196 = 0.000

.
# 9  
Old 03-15-2009
Hello Perderabo OR anyone else...can you help to fix this ?
# 10  
Old 03-15-2009
"sort" not working properly...

Hello all,
I have a file - 12.txt

cat 12.txt
===============================================
Number of executions = 2 Total execution time (sec.ms) = 0.009883
Number of executions = 8 Total execution time (sec.ms) = 0.001270
Number of executions = 135377 Total execution time (sec.ms) = 48.261439
Number of executions = 12 Total execution time (sec.ms) = 0.002608
Number of executions = 19513 Total execution time (sec.ms) = 1.529943
Number of executions = 25 Total execution time (sec.ms) = 0.008077
Number of executions = 50 Total execution time (sec.ms) = 0.029857
Number of executions = 4687 Total execution time (sec.ms) = 21.882761
Number of executions = 1 Total execution time (sec.ms) = 0.000086
Number of executions = 4 Total execution time (sec.ms) = 0.013008
Number of executions = 1 Total execution time (sec.ms) = 0.000226
Number of executions = 4699 Total execution time (sec.ms) = 0.791963
Number of executions = 1882 Total execution time (sec.ms) = 67.959492
Number of executions = 8 Total execution time (sec.ms) = 0.001410
Number of executions = 56232 Total execution time (sec.ms) = 235.199587
Number of executions = 3 Total execution time (sec.ms) = 1.742182
Number of executions = 23 Total execution time (sec.ms) = 0.003838
Number of executions = 9 Total execution time (sec.ms) = 0.000823
Number of executions = 8 Total execution time (sec.ms) = 0.032746
Number of executions = 24 Total execution time (sec.ms) = 0.040414
Number of executions = 134 Total execution time (sec.ms) = 1.165544
Number of executions = 14 Total execution time (sec.ms) = 0.004109
Number of executions = 1073 Total execution time (sec.ms) = 25.021018
Number of executions = 27838 Total execution time (sec.ms) = 189.024780
Number of executions = 402 Total execution time (sec.ms) = 2.425244
Number of executions = 11 Total execution time (sec.ms) = 0.146693
Number of executions = 30 Total execution time (sec.ms) = 0.105290
Number of executions = 28841 Total execution time (sec.ms) = 123.654048
Number of executions = 242 Total execution time (sec.ms) = 0.048610
Number of executions = 25 Total execution time (sec.ms) = 0.044363
.
.
<many more entries in file>
===============================================

I used to divide the number and then sort the result....
But it seems "sort"ing is not working properly....

cat 12.txt | awk '{ printf "%s/%s = %3.3f\n", $11, $5, $11/$5}' | sort -r -k3 > tot_time_div_num_exec

Now looking at...."tot_time_div_num_exec" file

9.396545/1 = 9.397
9.039183/1 = 9.039
76.712522/10 = 7.671
6.857941/1 = 6.858
18.470404/3 = 6.157
4.516811/1 = 4.517
4.214784/1 = 4.215
4.043929/1 = 4.044
3.868609/1 = 3.869
3.442802/1 = 3.443
3.198656/1 = 3.199
41.095447/2 = 20.548 <----why we have greater number here?
2.967361/1 = 2.967
11.660539/4 = 2.915
2.599642/1 = 2.600
7.414902/3 = 2.472
2.375463/1 = 2.375
4.402904/2 = 2.201
2.123307/1 = 2.123
47.139053/3 = 15.713
.
.
=====================

Please suggest me modification in my command and also tell me why sorting is not working?

Last edited by Rahulpict; 03-15-2009 at 07:23 PM..
# 11  
Old 03-15-2009
Quote:
Originally Posted by Rahulpict
Hello Perderabo OR anyone else...can you help to fix this ?
Now sure if we can, but....

Given a sample 12.txt file from the first post:
Code:
Number of executions = 2 Total execution time (sec.ms) = 0.009883
Number of executions = 8 Total execution time (sec.ms) = 0.001270
Number of executions = 135377 Total execution time (sec.ms) = 48.261439
Number of executions = 12 Total execution time (sec.ms) = 0.002608
Number of executions = 19513 Total execution time (sec.ms) = 1.529943
Number of executions = 25 Total execution time (sec.ms) = 0.008077
Number of executions = 50 Total execution time (sec.ms) = 0.029857
Number of executions = 4687 Total execution time (sec.ms) = 21.882761
Number of executions = 1 Total execution time (sec.ms) = 0.000086
Number of executions = 4 Total execution time (sec.ms) = 0.013008
Number of executions = 1 Total execution time (sec.ms) = 0.000226
Number of executions = 4699 Total execution time (sec.ms) = 0.791963
Number of executions = 1882 Total execution time (sec.ms) = 67.959492
Number of executions = 8 Total execution time (sec.ms) = 0.001410
Number of executions = 56232 Total execution time (sec.ms) = 235.199587
Number of executions = 3 Total execution time (sec.ms) = 1.742182
Number of executions = 23 Total execution time (sec.ms) = 0.003838
Number of executions = 9 Total execution time (sec.ms) = 0.000823
Number of executions = 8 Total execution time (sec.ms) = 0.032746
Number of executions = 24 Total execution time (sec.ms) = 0.040414
Number of executions = 134 Total execution time (sec.ms) = 1.165544
Number of executions = 14 Total execution time (sec.ms) = 0.004109
Number of executions = 1073 Total execution time (sec.ms) = 25.021018
Number of executions = 27838 Total execution time (sec.ms) = 189.024780
Number of executions = 402 Total execution time (sec.ms) = 2.425244
Number of executions = 11 Total execution time (sec.ms) = 0.146693
Number of executions = 30 Total execution time (sec.ms) = 0.105290
Number of executions = 28841 Total execution time (sec.ms) = 123.654048
Number of executions = 242 Total execution time (sec.ms) = 0.048610
Number of executions = 25 Total execution time (sec.ms) = 0.044363

and running:
Code:
awk '{ printf "%s/%s = %3.3f\n", $11, $5, $11/$5}' 12.txt| sort -r -k3,3n

we get:
Code:
48.261439/135377 = 0.000
1.529943/19513 = 0.000
0.791963/4699 = 0.000
0.048610/242 = 0.000
0.008077/25 = 0.000
0.004109/14 = 0.000
0.003838/23 = 0.000
0.002608/12 = 0.000
0.001410/8 = 0.000
0.001270/8 = 0.000
0.000823/9 = 0.000
0.000226/1 = 0.000
0.000086/1 = 0.000
0.029857/50 = 0.001
0.044363/25 = 0.002
0.040414/24 = 0.002
0.013008/4 = 0.003
235.199587/56232 = 0.004
123.654048/28841 = 0.004
0.105290/30 = 0.004
0.032746/8 = 0.004
21.882761/4687 = 0.005
0.009883/2 = 0.005
2.425244/402 = 0.006
189.024780/27838 = 0.007
1.165544/134 = 0.009
0.146693/11 = 0.013
25.021018/1073 = 0.023
67.959492/1882 = 0.036
1.742182/3 = 0.581

looks kosher to me......
I've just tested with the attached 12.txt from post #1 - it all looks good.
What OS are you under?

Last edited by vgersh99; 03-15-2009 at 07:54 PM..
# 12  
Old 03-15-2009
Please don't double post - it's against the rules.

Threads merged.
# 13  
Old 03-15-2009
Firstly, sorry for reposting but the folks who were responding to earlier thread were not understanding the problem at all and were just claming I changed the input file...this is ridiculous !! Thats why I moved to new1.....

Anyways...It looks like "vgersh99" you have understood my problem :-)
Here is my oslevel...

>oslevel -s
5300-07-01-0748


Looking forward to hear from you soon...
# 14  
Old 03-15-2009
Quote:
Originally Posted by Rahulpict
Firstly, sorry for reposting but the folks who were responding to earlier thread were not understanding the problem at all and were just claming I changed the input file...this is ridiculous !! Thats why I moved to new1.....

Anyways...It looks like "vgersh99" you have understood my problem :-)
Here is my oslevel...

>oslevel -s
5300-07-01-0748


Looking forward to hear from you soon...
Actually no - I'm in the same boat with everybody else (if you re-read my previous post): the sample file provided in the first post (and the attached file from the same post) when ran through the suggested awk script seem to return the correct data - RE-read my previous post with the quote data sample.

And no, I don't understand the 'oslevel': run 'uname -a' and post the output.
Good luck.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

"SQLPLUS -S " is not working in one environment where same code is working in another

"SQLPLUS -S " is not working in one environment where same code is working in another getting below error =================================== SQL*Plus: Release 11.2.0.3.0 Production Copyright (c) 1982, 2011, Oracle. All rights reserved. Use SQL*Plus to execute SQL, PL/SQL and SQL*Plus... (1 Reply)
Discussion started by: yogendra.barode
1 Replies

2. UNIX for Beginners Questions & Answers

Automate "touch" bash script not working.

#!/bin/bash -i SAVEIFS=$IFS IFS=$"\n\b" picc=$* if ; then echo $TDATE if ; then touch dummy touch -t "tdate" dummy touch -r "dummy" "$picc" else echo -e "No mod date value to apply. If there is one in your shell,\ninvoke \eStarted asking advice on this (on Linuxquestions.org).... (9 Replies)
Discussion started by: iamwrong
9 Replies

3. Shell Programming and Scripting

"if" Loop not working when executing script using cron

I am facing this weird issue where the script is working fine from the command line but when I am executing it from cron though it is working fine but the "if" loop is processing else part though I know that the if part of the logic is true and ideally the loop should execute the if portion. ... (3 Replies)
Discussion started by: sk2code
3 Replies

4. Shell Programming and Scripting

Why is sort not working properly here ?

Platform: RHEL 5.4 In the below text file I have strings like following. $ cat /tmp/mytextfile.txt DISK1 DISK10 DISK101 DISK102 DISK103 DISK104 DISK105 DISK106 DISK107 DISK108 DISK109 DISK110 DISK111 DISK112 DISK113 DISK114 (8 Replies)
Discussion started by: kraljic
8 Replies

5. Shell Programming and Scripting

"find . -printf" without prepended "." path? Getting path to current working directory?

If I enter (simplified): find . -printf "%p\n" then all files in the output are prepended by a "." like ./local/share/test23.log How can achieve that a.) the leading "./" is omitted and/or b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies

6. Shell Programming and Scripting

Script that "should work" it's not working.

Hi, this is my script: #!/bin/bash trabajo=$1 numero=`jobs | grep -n $trabajo | cut -d':' -f1` echo $trabajo echo $numero kill %$numero wait For some reason, numero=`jobs | grep -n $trabajo | cut -d':' -f1` that line wont save in numero the number I am looking for BUT if I write it... (7 Replies)
Discussion started by: lamachejo
7 Replies

7. Shell Programming and Scripting

"Print" not working in script

Hello everybody, I've gotten a script together that is designed to open a .bin file and read it 32 bits at a time and then add it to the checksum. However, the only issue that I have is that it will not print anything at the end. Can anyone help me? Also, is the & symbol used for restraining... (2 Replies)
Discussion started by: TeamUSA
2 Replies

8. Shell Programming and Scripting

"sed" command is not working in shell script

Hi All, I am not much strong in shell scripting... I am using sed command in my script to find and replace a string....... This is how script looks : ############# #!/usr/bin/ksh CONFIG_FILE=iom_test.txt FIND=`echo "NIS_FTP_SERVER1=123.456.iom.com"` REPLACE=`echo... (2 Replies)
Discussion started by: askumarece
2 Replies

9. Shell Programming and Scripting

script not working after "tail -f"

Hi Everyone , I am facing a strange problem i have made the follwing script to watch a appending log file (abc.log) but its not moving after the line tail -f , any suggestions ===================================== #!/bin/bash while true do tail -f abc.log | grep "exceptions" echo hi... (12 Replies)
Discussion started by: xander
12 Replies

10. UNIX for Advanced & Expert Users

pf not working properly even with only "pass in all" and "pass out all" rules

i have two rules in my pf.conf file, "pass in all" and "pass out all" i was having issues with getting pf working to begin with, so i went with starting from nothing and working on up. i have an ultrasparc ultra1 200e, with an added 4-port fast ethernet sbus card, running "3.4 GENERIC#85... (4 Replies)
Discussion started by: xyyz
4 Replies
Login or Register to Ask a Question