how to sort date in decimal values uptp two digits


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to sort date in decimal values uptp two digits
# 1  
Old 11-04-2009
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  
Old 11-04-2009
You missed the "filed separator" to specify for sort.
Code:
sort -t"|" -k2 file_name.txt

# 3  
Old 11-04-2009
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  
Old 11-04-2009
might be something like this :

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

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing with decimal places from last 4 digits

I have input file like below, 201424|9999|OSS|622010|RGT|00378228764 201424|8888|OM|587079|RGT|00284329675 201424|7777|OM|587076|RGT|00128671024 201424|6666|OM|581528|RGT|00113552084 Output should be like below, should add decimal (.) from last 4 digits. ... (2 Replies)
Discussion started by: vinothsekark
2 Replies

2. Shell Programming and Scripting

How to sort when there is variable length decimal points.?

Hi Experts, Quick quesion: I want to sort this in the file , but not working, when using # sort file name 305.932 456.470 456.469 456.468 456.467 172.089 456.467 456.466 456.465 111.573 111.578 111.572 111.572 87.175 87.174 75.898 (4 Replies)
Discussion started by: rveri
4 Replies

3. Shell Programming and Scripting

Sort Decimal number in UNIX

Hello Everyone, In one of my script, I would like to sort the decimal numbers. For e.g. If I have numbers like 1.0 1.1 1.2 2.0 2.1 3.0 4.0 5.0 6.0 7.0 7.1 7.10 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 I would like to sort them 1.0 1.1 1.2 2.0 2.1 3.0 4.0 5.0 6.0 7.0 7.1 7.2 7.3 7.4... (3 Replies)
Discussion started by: sachinrastogi
3 Replies

4. Shell Programming and Scripting

remove directories with two digits after decimal point

Hi everyone, I am new here and generally not experienced with linux. My question must be easy, but as for now I have no idea how to do it. I have lots of directories with numerical names, e.g. 50 50.1 50.12 etc. What I want is to leave directories with no or single digit after the decimal... (2 Replies)
Discussion started by: cabaciucia
2 Replies

5. Shell Programming and Scripting

number of digits after decimal

Hi All, I have a file of decimal numbers, cat file1.txt 1.1382666907 1.2603107334 1.6118799297 24.4995857056 494.7632588468 560.7633734425 ..... I want to see the output as only 7 digits after decimal (5 Replies)
Discussion started by: senayasma
5 Replies

6. Shell Programming and Scripting

How to get decimal values ?

Hi All, In my script I've written like this- c=$( expr 100 / 3);echo $c The output coming is 33. but I want to see 33.33, decimal values too. How to get that? Thanks, Naresh (3 Replies)
Discussion started by: NARESH1302
3 Replies

7. Shell Programming and Scripting

How to sort a field in a file having date values

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

8. UNIX for Advanced & Expert Users

Converting Binary decimal coded values to Ascii Values

Hi All, Is there any command which can convert binary decimal coded values to ascii values... i have bcd values like below оооооооооооо0о-- -v - Pls suggest a way to convert this. Thanks, Deepti.Gaur (3 Replies)
Discussion started by: gaur.deepti
3 Replies

9. Shell Programming and Scripting

How to sort decimal values in bash

Hi, I have a list of values from associative array from 0,..till 1.0000. I tried various sort options; sort -g, sort -nr but it still couldnt work. In other words, the numbers are not sorted accordingly. Please help. Thanks. (1 Reply)
Discussion started by: ahjiefreak
1 Replies
Login or Register to Ask a Question