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....
# 15  
Old 03-15-2009
uname -a
AIX panipuri 3 5 00C5EFD04C00
# 16  
Old 03-15-2009
I tried on diff machine...but same behavior :-(

$ uname -a
Linux matrix05 2.6.5-7.283-smp #1 SMP Wed Nov 29 16:55:53 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux
# 17  
Old 03-15-2009
I am with Perderabo and others...cannot figure out where you are getting those numbers for the execution times just doesn't make any sense. I ran the awk command on the sample input file you provided on AIX and the output was correct.
# 18  
Old 03-15-2009
Quote:
Originally Posted by shamrock
..... I ran the awk command on the sample input file you provided on AIX and the output was correct.
Did you get the (correct ) output in "SORTED" format ??
Like....
41.095447/2 = 20.548 <---- correct sort
47.139053/3 = 15.713 <---- correct sort
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
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
7.567567/4 = 1.892
1845.985563/1083 = 1.705
5.069130/3 = 1.690
.
Why don't you paste the command and exact output you get?
# 19  
Old 03-16-2009
The input...
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 the command and its output...
Code:
cat file | awk '{printf "%s/%s = %f\n", $11, $5,$11/$5}' | sort -r -k3
1.742182/3 = 0.580727
67.959492/1882 = 0.036110
25.021018/1073 = 0.023319
0.146693/11 = 0.013336
1.165544/134 = 0.008698
189.024780/27838 = 0.006790
2.425244/402 = 0.006033
0.009883/2 = 0.004941
21.882761/4687 = 0.004669
123.654048/28841 = 0.004287
235.199587/56232 = 0.004183
0.032746/8 = 0.004093
0.105290/30 = 0.003510
0.013008/4 = 0.003252
0.044363/25 = 0.001775
0.040414/24 = 0.001684
0.029857/50 = 0.000597
48.261439/135377 = 0.000356
0.008077/25 = 0.000323
0.004109/14 = 0.000293
0.000226/1 = 0.000226
0.002608/12 = 0.000217
0.048610/242 = 0.000201
0.001410/8 = 0.000176
0.791963/4699 = 0.000169
0.003838/23 = 0.000167
0.001270/8 = 0.000159
0.000823/9 = 0.000091
0.000086/1 = 0.000086
1.529943/19513 = 0.000078

# 20  
Old 03-16-2009
"shamrock" your getting correct result BECAUSE your using only first 30 lines from 12.txt (the file which I use as input)....

Actual 12.txt has 3052 lines....

I suggest you to run the same command which you pasted above
"cat file | awk '{printf "%s/%s = %f\n", $11, $5,$11/$5}' | sort -r -k3"

againt my input file 12.txt....you will see the incorrect output (non-sorted one) which I have pasted many times in this thread....I dont think you guys are getting my point....

Plz concentrate - use my complete 12.txt as input file....you will see non sorted result....as

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 <----why we have greater number here?
.
.

# 21  
Old 03-16-2009
After using the entire file you posted I see that the output file is sorted incorrectly and here's the fix...
Code:
awk '{printf "%s/%s = %f\n", $11, $5,$11/$5}' file | sort -k3rn

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