Sponsored Content
Full Discussion: Sort Data by Group !
Top Forums Shell Programming and Scripting Sort Data by Group ! Post 302552592 by csierra on Sunday 4th of September 2011 11:10:55 PM
Old 09-05-2011
Question Sort Data by Group !

Hello,

I have a file and i want to sort by third column and extract the three top lines of each group, it is determined by the second column (144, 89, 55, etc).

Could you please help me with the appropiate awk shell script

Code:
      XLY-XLP   144   0.592772       XLY-XLE   144   0.798121       XLY-XLF   144   0.682582       XLY-XLV   144   0.762279       XLY-XLI   144   0.893199       XLY-XLB   144   0.908553       XLY-XLK   144   0.902004       XLY-XLU   144   0.393566       XLP-^FTSE   89   0.85931       XLP-^N225   89   0.65297       XLP-USO   89   0.778344       XLP-UUP   89   0.464081       XLP-GLD   89   -0.7242       XLP-SLV   89   -0.38121       XLP-GXG   89   0.630136       XLP-FXE   89   -0.05132       XLP-SLV   55   -0.36012       XLP-GXG   55   0.717349       XLP-FXE   55   -0.00732       XLP-EUO   55   0.148117       XLP-KOL   55   0.846785       XLP-HAL   55   0.700265       XLP-ORCL   55   0.856371       XLP-C   55   0.806475

Sincerely,

Carlos
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sort cmd to get GROUP BY?

Is there any way using the sort command to get something like a GROUP BY clause? I'm trying to sort through race_event records and group them by those individuals that raced together in the same race on the same date at the same track, but i run into a problem when there were days when the track... (6 Replies)
Discussion started by: RacerX
6 Replies

2. Shell Programming and Scripting

Sort, group rows

I wrote script in bash which generates this report: User1,admin,rep,User2,shell,path1,x1,r1 User2,admin,rep,User7,shell,path1,x1,r1 User3,admin,rep,User4,shell,path1,x1,r1 User4,admin,rep,User3,shell,path1,x1,r1 User5,admin,rep,User1,shell,path1,x1,r1 User6,admin,rep,User5,shell,path1,x1,r1... (6 Replies)
Discussion started by: patrykxes
6 Replies

3. Shell Programming and Scripting

awk - sort, then print the high value for each group

Hi @ all I'm trying to achive to this problem, I've a 2-column composed file as the following: 192.168.1.2 2 192.168.1.3 12 192.168.1.2 4 192.168.1.4 3 cpc1-swan1-2-3-cust123.swan.cable.ntl.com 4 192.168.1.3 5 192.168.1.2 10 192.168.1.4 8... (8 Replies)
Discussion started by: m4rco-
8 Replies

4. UNIX for Dummies Questions & Answers

sort group of n lines base on pattern in first line

I have record having 10 fields and each field being printed on a new line, first line cotains name of exchange, 2nd line stock name, third line stock price, etc etc... now i want to retrieve data only for a particular exchanged and that too only 2nd and 3rd row info... NSE RNRL 70 12 1... (1 Reply)
Discussion started by: manishma71
1 Replies

5. Shell Programming and Scripting

AWK or KSH : Sort, Group and extract from 3 files

Hi, I've the following two CSV files: File1.csv File2.csv Class,Student# Student#,Marks 1001,6001 6002,50 1001,6002 6001,60 1002,7000 ... (3 Replies)
Discussion started by: Matrix2682
3 Replies

6. Shell Programming and Scripting

Split file by data group

Hi all, I'm having a little trouble solving a file split I need to get done. I have the following data: 1. Light 1A. Light Soft texture: it's soft color: the color value is that of something light vital statistics: srm: 23 og: 1.035 sp: 1.065 comment: this is nice if you like... (8 Replies)
Discussion started by: mkastin
8 Replies

7. Shell Programming and Scripting

Sort the file contents in each group....print the group title as well

I've this file and need to sort the data in each group File would look like this ... cat file1.txt Reason : ABC 12345-0023 32123-5400 32442-5333 Reason : DEF 42523-3453 23345-3311 Reason : HIJ 454553-0001 I would like to sort each group on the last 4 fileds and print them... (11 Replies)
Discussion started by: prash184u
11 Replies

8. UNIX for Advanced & Expert Users

Group/Sort logs by thread number

Hello Experts, For the following sample log, can you tell me how I can sort it or group it by thread number. To be specific, I just want to group them together so that its easy to analyize. Thanks. 2012-08-17 00:00:06,369 INFO ExecuteThread: '33' for queue:... (2 Replies)
Discussion started by: samjna
2 Replies

9. Shell Programming and Scripting

De-group data

Hi, some help is highly appreciated, I want to de-group my data for statistical analysis. I made up some sample data, there shouldnt be repeated lines in the output. My data is in excel but I can make it tab-delimited text. A B,C A B,D,E X Y X Y,ZExpected output A B A C A D A E X Y... (3 Replies)
Discussion started by: ritakadm
3 Replies

10. Shell Programming and Scripting

How to group similar data?

Hello everybody: I want rearrange about 5 million rows (with 300 columns) into groups. Data looks like the following: where there were various experiments (column 2) conducted at different locations (column headers in top row column 4 onwards) in different years (column 1) using instruments... (0 Replies)
Discussion started by: sheetalk
0 Replies
OUTPUT(5)							File Formats Manual							 OUTPUT(5)

NAME
output - output data file formats DESCRIPTION
This manual page describes the output formats of the files created by the Yagi-Uda project's output program. The files are ASCII file, so can be analysed with any graph plotting program. Example of a .dat File Below is a typical .dat file, for a 4ele 144-146MHz beam, optimised for a huge (and useless) FB. # Driven=1 parasitic=3 total-elements=4 design=145.000MHz # Checked from 144.000MHz to 146.000MHz. f(MHz) E(deg) H(deg) R jX VSWR Gain(dBi) FB(dB) SideLobes(dB) 144.000 54.7 71.5 44.47 -2.35 1.136 9.386 21.944 16.650 144.500 54.0 70.1 41.34 -0.75 1.210 9.553 27.244 17.153 145.000 53.2 68.4 37.55 1.61 1.335 9.742 103.055 17.777 145.500 52.3 66.6 33.26 5.00 1.530 9.947 25.734 18.547 146.000 51.3 64.6 28.77 9.63 1.832 10.149 18.919 18.919 What is what in the .dat file The f(MHz) column is the frequency (MHz) at which the data is evaluated at. The E(deg) column is the approximate 3dB E-plane bandwidth calculated to the nearest 0.1 degree. The H(deg) column is the approximate 3dB H-plane bandwidth calculated to the nearest 0.1 degree. The (R) column is the input resistance in Ohms. The (jX) column is the input reactance in Ohms. The (VSWR) column is the input VSWR, usually refered to a 50 Ohm input, but this may be changed. The Gain (dBi) column is the gain at theta=90 degrees, which is the forward direction of the beam. It is possible that a higher gain occurs at other than 90 degrees, but this is not taken into account. The antenna is seriously at fault if this occurs. The FB(dB) column is the front to back ratio in dB. The Sidelobes(dB) column is the minimum level in dB down from the peak gain of any sidelobe. This is not calculated unless the '-c' option is used, and then only on some optimisation techniques. Example of a .gai File The following is a small section of the .gai file. f(MHz) theta gain-E(dBi) G(E)-peak phi gain-H(dBi) G(H)-peak 144.0000 -90.0000 -12.5584 -21.9444 -180.0000 -12.5584 -21.9444 144.0000 -45.0000 -7.3507 -16.7367 -135.0000 -3.5971 -12.9830 144.0000 0.0000 -999.0000 -1008.3860 -90.0000 -0.9010 -10.2870 144.0000 45.0000 0.1848 -9.2012 -45.0000 4.0261 -5.3599 144.0000 90.0000 9.3860 0.0000 0.0000 9.3860 0.0000 144.0000 135.0000 0.1848 -9.2012 45.0000 4.0261 -5.3599 144.0000 180.0000 -999.0000 -1008.3860 90.0000 -0.9010 -10.2870 144.0000 225.0000 -7.3507 -16.7367 135.0000 -3.5971 -12.9830 144.0000 270.0000 -12.5584 -21.9444 180.0000 -12.5584 -21.9444 What is what in the .gai file The f(MHz) column is the frequency in MHz. The theta column is the angle theta, for which the next two columns refer. The gain-E(dBi) is the gain at theta, relative to an isotropic radiator. This is the E-plane gain. Hence at the peak (theta), this gives the peak forward gain. The G(E)-peak is the gain at theta, relative to the peak gain. Hence at the peak (theta=90 degrees), this is zero. The phi column has nothing to do with the previous 3 columns. It is the angle for which the next two columns refer. The gain-H(dBi) is the gain at phi, relative to an isotropic radiator. This is the H-plane gain. Hence at the peak (phi=0), this gives the peak forward gain. The G(H)-peak is the gain at phi, relative to the peak gain. Hence at the peak (phi=0 degrees), this is zero. Example of a .up File The .up file list the improvements made by optimise to an antenna design. Starting from the original design, the file is appended each time a new better design is found. Here is an example, where the final line is the performance of the 4ele beam with the .dat file shown ear- lier. 1 7.57dBi, 16.93dB F/B, Z=(31.77-56.34j) Ohms, VSWR=3.95, SL=16.95 dB 84 7.58dBi, 16.93dB F/B, Z=(31.78-56.32j) Ohms, VSWR=3.95, SL=16.95 dB 623 7.58dBi, 16.93dB F/B, Z=(31.78-56.28j) Ohms, VSWR=3.95, SL=16.95 dB 89345 9.74dBi, 103.06dB F/B, Z=(37.55 +1.61j) Ohms, VSWR=1.33, SL=17.78 dB What is what in the .up file The first column is an integer specifying the iteration. The other columns, going from left to right are gain(dBi), FB, input impedance, VSWR and level of the most significant sidelobe, in dB down on the peak gain. SEE ALS0 yagi(1), output(1), input(1), optimise(1), first(1) and yagi(5). AUTHORS
Dr. David Kirkby G8WRB (david.kirkby@onetel.net), with help with converting to DOS from Dr. Joe Mack NA3T (mack@fcrfv2.ncifcrf.gov). Version 1.16 24th October 2000 OUTPUT(5)
All times are GMT -4. The time now is 10:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy