Sponsored Content
Full Discussion: sorting question......
Top Forums Shell Programming and Scripting sorting question...... Post 302344695 by Tytalus on Monday 17th of August 2009 10:21:32 AM
Old 08-17-2009
Not sure I understand what you're aiming for here.

It looks like the for each possible value of the second field you are wanting to return only one line, but what criteria are you using to decide on your return. e.g.:

First three lines:
Code:
2009-01-01 10665 Begin 02:25:23
2009-01-02 10665 Begin 20:54:11
2009-01-03 10665 Begin 05:31:17

Last three lines:

2009-01-06 10671 Begin 00:25:31
2009-01-06 10671 Begin 02:17:50
2009-01-06 10671 Begin 03:55:32

lines highlighted in bold appear to be the ones you're after, but I do not see quite how you decided on these...

Is it simply the line with the greatest timestamp in the third field that you want returned for each value in the second field, regardless of the date in the first field?

In which case - can be leaned up somewhat, but:

Code:
#  sort -n +3 infile | awk '{t[$2]=$0}END{for (i in t){print t[i]}}' | sort -n +1
2009-01-02 10665 Begin 20:54:11
2009-01-03 10666 Begin 06:01:38
2009-01-03 10667 Begin 06:33:18
2009-01-03 10668 Begin 07:00:42
2009-01-03 10669 Begin 07:28:14
2009-01-03 10670 Begin 07:56:09
2009-01-06 10671 Begin 03:55:32

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Noob sorting question

Ok here is the deal, I have a command given to me by some systems guy who I cannot get ahold of on the weekend without paying him alot of money to help me. I need to get this done before Monday as I am just getting pummeled by DOS attacks. The comand given was.... netstat -ntu | awk '{print... (1 Reply)
Discussion started by: Hexabah
1 Replies

2. UNIX for Dummies Questions & Answers

sorting question

How can I sort lines in a file in a consistent, user-defined way that is not alphabetical, numeric, or patterned in any other way (e.g., sort a bunch of 5 line files to always print lines 2,5,3,4,1)? Thanks in advance. (4 Replies)
Discussion started by: darwin_886
4 Replies

3. Shell Programming and Scripting

Sorting Question

Hi All I have a CSV file where 3rd and 4th fields are date and time it's a session log file printing the date and time per session Now, I want to create a statistics of how many sessions per date and Time I managed a script for sessions per hour Code: #!/bin/bash #This Shell Script... (3 Replies)
Discussion started by: The Owl
3 Replies

4. UNIX for Dummies Questions & Answers

Sorting question

i have list of files: Wang CVPR 09.pdf Yaacob AFGR 99.pdf Shi CVPR 04.pdf ..... how can i sort with single line this directory so the output will be in the next format: <year>\t<conference/journal>\t<author list> - t is tab (its sort by the year) example: 1999 CVIU ... (2 Replies)
Discussion started by: nirnir26
2 Replies

5. UNIX for Dummies Questions & Answers

Sorting help

i have list of files: Wang De Wong CVPR 09.pdf Yaacob AFGR 99 Second edition.pdf Shimon CVPR 01.pdf Den CCC 97 long one.pdf Ronald De Bour CSPP 04.pdf ..... how can i sort this directory so the output will be in the next format: <year>\t<conference/journal>\t<author list> - t is tab (its... (1 Reply)
Discussion started by: nirnir26
1 Replies

6. UNIX for Advanced & Expert Users

HELP on sorting

hi everyone, I am kind of new to this forum. I need help in sorting this data out accordingly, I am actually doing a traceroute application and wants my AS path displayed in front of my address like this; 192.168.1.1 AS28513 AS65534 AS5089 AS5089 .... till the last AS number and if possible... (1 Reply)
Discussion started by: sam127
1 Replies

7. Shell Programming and Scripting

Sorting HELP

Hi, I have posted related topic but as i continue the research I find more need to sort the data. AS(2607:f278:4101:11:dead:beef:f00f:f), AS786 AS6453 AS7575 AS7922 AS(2607:f2e0:f:1db::16), AS786 AS3257 AS36252 AS786 AS3257 AS36252 AS(2607:f2f8:1700::2), AS786 AS6939 AS25795 ... (6 Replies)
Discussion started by: sam127
6 Replies

8. Shell Programming and Scripting

sorting

Hi all, Does anyone can help me the following question? I would like to write an AWK script. In the following input file, each number in "start" is paired with numbers in column "end". No Start End A 22,222,33,22,1233,3232,44 555,333,222,55,1235,3235,66... (7 Replies)
Discussion started by: phoeberunner
7 Replies

9. UNIX for Dummies Questions & Answers

Quick Question: Sorting

Hi fellow linuxers I have a quick question... I would like to sort the numbers in each line that are within a file, and I want to sort them so that the numbers in each line go from SMALLEST to HIGHEST. For example, my file looks like this: 6 4 2 3 1 5 7 8 15 16 11 13 12 14 20 18 19 17 24 26... (7 Replies)
Discussion started by: lucshi09
7 Replies

10. Shell Programming and Scripting

Question about sorting -- how to pass an array to a function

Hi, guys I just wanted to sort the elements of an array ascendingly. I know the following code does work well: array=(13 435 8 23 100) for i in {0..4} do j=$((i+1)) while ] do if } -le ${array} ]] then : else min=${array} ${array}=${array} ${array}=$min fi... (5 Replies)
Discussion started by: franksunnn
5 Replies
Net::DNS::Question(3pm) 				User Contributed Perl Documentation				   Net::DNS::Question(3pm)

NAME
Net::DNS::Question - DNS question class SYNOPSIS
"use Net::DNS::Question" DESCRIPTION
A "Net::DNS::Question" object represents a record in the question section of a DNS packet. METHODS
new $question = Net::DNS::Question->new("example.com", "MX", "IN"); Creates a question object from the domain, type, and class passed as arguments. RFC4291 and RFC4632 IP address/prefix notation is supported for queries in in-addr.arpa and ip6.arpa subdomains. parse ($question, $offset) = Net::DNS::Question->parse($data, $offset); Parses a question section record at the specified location within a DNS packet. The first argument is a reference to the packet data. The second argument is the offset within the packet where the question record begins. Returns a Net::DNS::Question object and the offset of the next location in the packet. Parsing is aborted if the question object cannot be created (e.g., corrupt or insufficient data). qname, zname print "qname = ", $question->qname, " "; print "zname = ", $question->zname, " "; Returns the domain name. In dynamic update packets, this field is known as "zname" and refers to the zone name. qtype, ztype print "qtype = ", $question->qtype, " "; print "ztype = ", $question->ztype, " "; Returns the record type. In dymamic update packets, this field is known as "ztype" and refers to the zone type (must be SOA). qclass, zclass print "qclass = ", $question->qclass, " "; print "zclass = ", $question->zclass, " "; Returns the record class. In dynamic update packets, this field is known as "zclass" and refers to the zone's class. print $question->print; Prints the question record on the standard output. string print $qr->string, " "; Returns a string representation of the question record. data $qdata = $question->data($packet, $offset); Returns the question record in binary format suitable for inclusion in a DNS packet. Arguments are a "Net::DNS::Packet" object and the offset within that packet's data where the "Net::DNS::Question" record is to be stored. This information is necessary for using compressed domain names. COPYRIGHT
Copyright (c) 1997-2002 Michael Fuhr. Portions Copyright (c) 2002-2004 Chris Reinhardt. Portions Copyright (c) 2003,2006-2009 Dick Franks. All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
perl(1), Net::DNS, Net::DNS::Resolver, Net::DNS::Packet, Net::DNS::Update, Net::DNS::Header, Net::DNS::RR, RFC 1035 Section 4.1.2 perl v5.14.2 2009-12-30 Net::DNS::Question(3pm)
All times are GMT -4. The time now is 08:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy