Sponsored Content
Full Discussion: Sort complicated two fields
Top Forums Shell Programming and Scripting Sort complicated two fields Post 302186625 by Franklin52 on Thursday 17th of April 2008 03:22:45 PM
Old 04-17-2008
This should gives you the desired output:

Code:
awk ' BEGIN{FS=OFS=","}
a[$5] {
  split($2,s,":")
  if(t[$5] < s[1]*3600+s[2]*60+s[3]) { 
    t[$5]=s[1]*3600+s[2]*60+s[3]
    a[$5]=$0
    next
  }
}
{
a[$5]=$0
t[$5]=s[1]*3600+s[2]*60+s[3]
}
END {for(i in a){print a[i]}}
' file

Regards
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sort fields

I have a large csv file that looks like this: 14 ,M0081,+000000001,200302,+00000100500, 14 ,M0081,+000000004,200301,+00000100500, 14 ,M0081,+000000005,200305,+00000100500, 14 ,M0081,+000000000,200205,+00000100500, 14 ,M0081,+000000008,200204,+00000100500, ... (2 Replies)
Discussion started by: edog
2 Replies

2. Shell Programming and Scripting

sort sum fields

HI ALL, i have a problem when i do a sort sum with many fields. Is there a limit for fields? Do you know a solution? thanks in advance. the shell is: # SORT1 SORT1_rcode=777 if ; then echo "USE $DARSEQ/OTPU.FTPEPREC RECORD F,1000 " > $DARPARSRT/TPEKL508.SORT1_$$.srt ... (6 Replies)
Discussion started by: tullo
6 Replies

3. Shell Programming and Scripting

sort on fields

Hi I have following fixed width file and I have to sort on 2 fields ABC 111222333002555 77788 ABC 111222333004555 77788 ABC 111222333001555 77788 ABC 111222333003555 77788 ABC 111222333005555 77788 one is from field1 to field 3 "ABC" and another is on 14 to 16 "002" (based on first... (1 Reply)
Discussion started by: mgirinath
1 Replies

4. Shell Programming and Scripting

Seperate complicated fields with awk

Hello, I want to separate fields from an log output like this: 11-JUL-2008 23:14:25 * (CONNECT_DATA=(SERVICE_NAME=WUMMER.IM.HERE.EXELLENT.COM)(CID=(PROGRAM=D:\oracle\product\10.2.0\client_1\jdk\jre\bin\java.exe)(HOST=X900005199)(USER=FTET1))) *... (6 Replies)
Discussion started by: sdohn
6 Replies

5. UNIX for Dummies Questions & Answers

sort on three fields

Hi I would like to sort a csv file. It has 50 fields and approx 1400000 lines. I want to sort by three columns as follows. Say sort on coulmn 5, if entries are equal sort on column 3 if this is also equal sort on column 6. It seems that this is possible for 5 then 3 i.e. sort -t "," -k 5,5 -k... (1 Reply)
Discussion started by: turquoise_man
1 Replies

6. UNIX for Dummies Questions & Answers

Sort on first two fields -only-

Hey, I have a file i want to sort. It contains these kind of lines: FirstName LastName buyID buyType Eg: John Doe 22 Car Jane Simpson 4 Headset John Doe 11 Telephone Now if I use the sort command on it cat purchases.txt | sort -k1,1 -k2,2 it would also sort the third and 4th field:... (4 Replies)
Discussion started by: ce3c
4 Replies

7. Shell Programming and Scripting

Unique sort with three fields

I have another file with three columns A,B,C as below 123,1,502 123,2,506 123,3,702 234,4,101 235,5,104 456,6,104 456,7,100 i want to sort such that i get a unique value in column A, and for those with multiple value in A, i want the lowest value in C. output should be Code:... (3 Replies)
Discussion started by: dealerso
3 Replies

8. Shell Programming and Scripting

doing a sort on first two fields

hi, i'm having a file stg_ff.txt which contains 10 fields,which contains millions of records i need to cat the first 10 rows in the file after doing a sorting on the first two fields i n the file. can any body help me on this. regards Angel (4 Replies)
Discussion started by: angel12345
4 Replies

9. Shell Programming and Scripting

Sort on first fields only

Please advice in this. Input file 100,vvvt 201,unb 100,sos 301,abc 99,gang desired output 99,gang 100,vvvt 100,sos 201,unb 301,abc Means if first fields are same ( here 100) the do not sort. (4 Replies)
Discussion started by: theshashi
4 Replies

10. Shell Programming and Scripting

awk sort based on difference of fields and print all fields

Hi I have a file as below <field1> <field2> <field3> ... <field_num1> <field_num2> Trying to sort based on difference of <field_num1> and <field_num2> in desceding order and print all fields. I tried this and it doesn't sort on the difference field .. Appreciate your help. cat... (9 Replies)
Discussion started by: newstart
9 Replies
FvwmClean(1)						      General Commands Manual						      FvwmClean(1)

NAME
FvwmClean - the FVWM desktop clutter reduction module SYNOPSIS
FvwmClean is spawned by fvwm, so no command line invocation will work. DESCRIPTION
The FvwmClean module performs actions on windows which have not had the keyboard focus for a specific length of time. This is intended to help alleviate the problem of leaving programs running in unused portions of your desktop. FvwmClean reads the same .fvwmrc file as fvwm reads when it starts up, and looks for lines similar to "*FvwmNoClutter 3600 Iconify". COPYRIGHTS
The FvwmClean program, and the concept for interfacing this module to the Window Manager, are all original work by Robert Nation Copyright 1994, Robert Nation. No guarantees or warranties or anything are provided or implied in any way whatsoever. Use this program at your own risk. Permission to use this program for any purpose is given, as long as the copyright is kept intact. INITIALIZATION
During initialization, FvwmClean will eventually search a configuration file which describes the time-outs and actions to take. The con- figuration file is the same file that fvwm used during initialization. If the FvwmClean executable is linked to another name, ie ln -s FvwmClean OtherClutter, then another module called OtherClutter can be started, with a completely different configuration than FvwmClean, simply by changing the keyword FvwmClean to OtherClutter. This way mul- tiple clutter-reduction programs can be used. INVOCATION
FvwmClean can be invoked by inserting the line 'Module FvwmClean' in the .fvwmrc file. This can be placed on a line by itself, if FvwmClean is to be spawned during fvwm's initialization, or can be bound to a menu or mouse button or keystroke to invoke it later. Fvwm will search directory specified in the ModulePath configuration option to attempt to locate FvwmClean. CONFIGURATION OPTIONS
FvwmClean reads the same .fvwmrc file as fvwm reads when it starts up, and looks for lines similar to "*FvwmClean 3600 Iconify". The format of these lines is "*FvwmClean [time] [command]", where command is any fvwm built-in command, and time is the time in seconds between when a window looses focus and when the command is executed. At most 3 actions can be specified. AUTHOR
Robert Nation 3rd Berkeley Distribution Jan 28 1994 FvwmClean(1)
All times are GMT -4. The time now is 01:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy