The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
How to serach for Values grater tan 4 digits in a file using Awk Command samura Shell Programming and Scripting 1 09-15-2009 09:15 AM
How to sort a field in a file having date values risshanth Shell Programming and Scripting 4 06-04-2008 05:03 AM
Converting Binary decimal coded values to Ascii Values gaur.deepti UNIX for Advanced & Expert Users 3 04-02-2008 12:33 PM
How to sort decimal values in bash ahjiefreak Shell Programming and Scripting 1 01-21-2008 09:25 AM

Reply
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 3 Weeks Ago
jojo123 jojo123 is offline
Registered User
  
 

Join Date: May 2009
Posts: 51
how to sort date in decimal values uptp two digits

Hi all,

there is a data in a file wich loks likes
Code:
 
00:00:49|24.48|
00:01:49|22.83|
00:02:49|22.07|
00:03:49|20.72|
00:04:49|21.28|
00:05:49|21.22|
00:06:49|21.38|
00:07:49|20.93|
00:08:49|21.27|
00:09:49|20.65|
00:10:49|19.42|
00:11:49|21.93|
00:12:49|20.62|
00:13:49|20.23|
00:14:49|20.23|
00:15:49|20.48|
00:16:49|21.50|
00:17:49|19.95|
00:18:49|20.47|
00:19:49|19.40|
00:20:49|17.23|
00:21:49|19.47|
00:22:49|19.27|
00:23:49|18.02|
00:24:49|18.78|
00:25:49|17.53|
00:26:49|18.40|
00:27:49|17.48|
00:28:49|17.32|
00:29:49|16.62|
I need to sort second feild in ascending order..

HTML Code:
I tried several command but i am not getting my desired output, Can anyone hep me out.
here's what i tried

Code:
cat file.wri | sort -n -k 2.1 -k 2.2 -k 2 | more 
cat file.wri | sort -n -k 4.1 -k 4.2 -k 4 | more 
cat file.wri | sort -n -k 10.1 -k 10.2 -k 10 | more 
cat file.wri | sort -n -k 10 -k 11 | more 
cat file.wri | sort -n -k 9 -k 10 | more
  #2 (permalink)  
Old 3 Weeks Ago
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 474
You missed the "filed separator" to specify for sort.
Code:
sort -t"|" -k2 file_name.txt
  #3 (permalink)  
Old 3 Weeks Ago
jojo123 jojo123 is offline
Registered User
  
 

Join Date: May 2009
Posts: 51
hmm thankz panyam for the reply, but i m afraid this dont work as the output did sort but accroding to first digit. here's what the output

Code:
03:22:49|3.90|
03:25:49|3.90|
03:44:49|3.97|
05:09:49|3.98|
10:42:49|30.02|
10:39:49|30.07|
14:21:49|30.07|
16:45:49|39.97|
17:20:49|39.98|
22:11:49|39.98|
03:20:49|4.00|
03:30:49|4.03|
05:08:49|4.07|
03:33:49|4.08|
i.e it did sorted according to second feild but its taking into account the first charcter.

i.e if valule is 39.98 its sorting data according to 3 and and then later 4.00

i want it should be sorted by taking into account the digits before point(.) i.e. larger value at the end.

Hope its clear now
  #4 (permalink)  
Old 3 Weeks Ago
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 474
might be something like this :

Code:
sort -t"|" -n -k2  file_name
Reply

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 03:38 AM.


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