The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
conversion of different timestamp to standard timestamp dprakash Shell Programming and Scripting 2 04-14-2009 03:23 PM
Convert DD-MMM-YYYY to MM-DD-YYYY nuthalapati Shell Programming and Scripting 2 04-06-2009 04:25 PM
converting the date field from dd/mm/yyyy to yyyy/mm/dd pareshan Shell Programming and Scripting 4 03-17-2009 05:43 PM
sort file on timestamp and a alphabetic code in it harshada UNIX for Dummies Questions & Answers 5 10-03-2008 10:35 AM
Change Date from dd-mmm-yyyy to mm/dd/yyyy stringzz Shell Programming and Scripting 9 09-15-2008 11:09 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-05-2009
sureshg_sampat sureshg_sampat is offline
Registered User
  
 

Join Date: Nov 2006
Location: Czech Republic
Posts: 49
sort for timestamp information-YYYY-MM-DD HH:MM:SS

Dear all,

Please advice how do I sort a file based on timestamp information. I want to sort the second column in asc/desc order which has timestamp information in format YYYY-MM-DD HH:MM:SS

Example
File - Input.txt contains
cat ss.txt
100|2009-03-30 11:38:43
141|2009-06-01 12:12:01
200|2009-06-01 12:10:01
200|2009-06-01 12:11:01

When i run command below, I get result as
sort -t'|' -k2,n Input.txt
100|2009-03-30 11:38:43
141|2009-06-01 12:12:01
200|2009-06-01 12:10:01
200|2009-06-01 12:11:01

But the correct expected output [ which means HH:MM:SS part should also be sorted] is
100|2009-03-30 11:38:43
141|2009-06-01 12:10:01
200|2009-06-01 12:11:01
200|2009-06-01 12:12:01

How do I get this expected output, please advice

Regards,
SUresh
  #2 (permalink)  
Old 06-05-2009
unSpawn unSpawn is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 53
Are you using some alias or LC_ALL setting? Works as advertised for me.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0