07-28-2009
Sort two columns in a field, one of them being a date
Hi,
I have a set of columns in a csv file, my first row being an integer and 2nd being a date. I want to first sort it using the first column and then by the second.
for e.g. i have ,
1234,09/05/2009,hi
5678,01/01/2008,hi
1234,11/03/2006,hello
5678,28/07/2010,hello
i tried this but wont work because the separator is "," :::
sort -t "," -k1 -k2.7,2.10 -k2.4,2.5M -k2.1,2.2 test.csv > hi.csv
Thanks in advance,
SD
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hello,
i have a table contain many columns delimited by blank.
i want to sort this table by the 2 columns and 3 one and i want to keep the first line inchanged?
how can i do using the sort command?
thanks
table like :
field1 field2 field3 field4
x y z b
t h r n
.. (4 Replies)
Discussion started by: kamel.seg
4 Replies
2. Shell Programming and Scripting
Hi All,
I am having a pipe delimited file .In this file the 3rd column is having date values.I need to get the min date and max date from that file.
I have used
cut -d '|' test.dat -f 3|sort -u
But it is not sorting the date .How to sort the date column using unix commands
Thanks ... (4 Replies)
Discussion started by: risshanth
4 Replies
3. Shell Programming and Scripting
:cool:
Hi all,
I have a pecular issue in sorting these files in Solaris environment.
All the below files are modified on November 4th, but I want to sort these files as per date column (eg: 01May07_1623 = ddmmmyy_hhmm)
Nov 4 18:27 SONYELEC00.GI22973.01May07_1623.gpg
Nov 4 18:27... (4 Replies)
Discussion started by: shivaastrogun
4 Replies
4. Shell Programming and Scripting
I want to sort alphabetically on the first field and sort in descending numerical order on the 2nd field. With a normal "sort -r -n" it does this:
abc ||| 5e-05 ||| bla
abc ||| 3 ||| ble
def ||| 1 ||| abc
def ||| 0.2 ||| def
As you can see it ignores the fact that 5e-05 is actually 0.00005... (1 Reply)
Discussion started by: FrancoisCN
1 Replies
5. UNIX for Dummies Questions & Answers
Hello Group,
I would like to sort the below file by date (first year then month and day) and I used the following command but it does not work
sort -n -t"/" -k3 -k1 -k2
"sample original file"
12/28/2009,1.0353
12/31/2009,1.0357
12/30/2009,1.0364
12/29/2009,1.0366
12/24/2009,1.0386... (6 Replies)
Discussion started by: csierra
6 Replies
6. Shell Programming and Scripting
SOLVED : (17 Replies)
Discussion started by: Glitch100
17 Replies
7. UNIX for Advanced & Expert Users
Hi colleagues,
I have this output, i need sort for 7th and 8th columns, the column 7th is date mm/dd/yyyy format and column 8th is time hh:mm:ss.number
PRUEBA 1263 0007 1 0 7131292 03/25/2013 16:43:04.159976 PROCESS
PRUEBA1 666 0146 1 0 11600064 ... (1 Reply)
Discussion started by: systemoper
1 Replies
8. Shell Programming and Scripting
Hi Experts,
I have a filelist collected from another server , now want to sort the output using date/time stamp filed.
- Filed 6, 7,8 are showing the date/time/stamp.
Here is the input:
#----------------------------------------------------------------------
-rw------- 1 root ... (3 Replies)
Discussion started by: rveri
3 Replies
9. UNIX for Dummies Questions & Answers
New to unix.
I need to sort the records of a file by a control number field. That field is in POS 16 through 28. How do I do that? There are no delimiters, or spaces to separate fields.
See example below. Each line is a record.
REC1CCYYMMDD0018888888888888ABCDE... (1 Reply)
Discussion started by: jclanc8
1 Replies
10. AIX
I wanted to sort the below data on 4th field(comma seperator) based on month and date and time on AIX OS.
Input data:
3,AJ,30 Jul 06:30,30 Jul 06:30
5,AJ,30 Jul 06:30,30 Jul 06:49
10,AJ,30 Jul 06:30,02 Jan 05:41
4,AJ,30 Jul 06:30,30 Jul 06:36
2,AJ,30 Jul 06:30,28 Jul 06:45
9,AJ,30 Jul... (2 Replies)
Discussion started by: Amit Joshi
2 Replies
LEARN ABOUT PHP
ibase_fetch_assoc
IBASE_FETCH_ASSOC(3) 1 IBASE_FETCH_ASSOC(3)
ibase_fetch_assoc - Fetch a result row from a query as an associative array
SYNOPSIS
array ibase_fetch_assoc (resource $result, [int $fetch_flag])
DESCRIPTION
Fetch a result row from a query as an associative array.
ibase_fetch_assoc(3) fetches one row of data from the $result. If two or more columns of the result have the same field names, the last
column will take precedence. To access the other column(s) of the same name, you either need to access the result with numeric indices by
using ibase_fetch_row(3) or use alias names in your query.
PARAMETERS
o $result
- The result handle.
o $fetch_flag
-$fetch_flag is a combination of the constants IBASE_TEXT and IBASE_UNIXTIME ORed together. Passing IBASE_TEXT will cause this
function to return BLOB contents instead of BLOB ids. Passing IBASE_UNIXTIME will cause this function to return date/time values
as Unix timestamps instead of as formatted strings.
RETURN VALUES
Returns an associative array that corresponds to the fetched row. Subsequent calls will return the next row in the result set, or FALSE if
there are no more rows.
SEE ALSO
ibase_fetch_row(3), ibase_fetch_object(3).
PHP Documentation Group IBASE_FETCH_ASSOC(3)