Sponsored Content
Top Forums Shell Programming and Scripting How to sort when there is variable length decimal points.? Post 302830957 by rveri on Wednesday 10th of July 2013 12:02:45 AM
Old 07-10-2013
Sorry my bad! I am able to figure it out now,
I was trying sorting this values which were in column 5th, However at a point the 4rth and 5th column touching together and it was making one column sort , so the output was not coming right.

Yoda, Don, thanks. Don, You are right, OS X , is correct. and the command is correct. my data file had problem.

Thanks Jim , able to figure it out.

I was trying sort -rnk 5 and the output was not coming as expected:
Code:
cmihpu28 :  C2PDI03 :: 75.894    Days::
cmihpu29 :  C2PDI10 :: 75.893    Days::
cmihpu38 :  C2PDI05 :: 75.893    Days::
talhpu27 :  A2DAS   :: 73.242    Days::
talhpu28 :  C2SPO   :: 52.292    Days::
cmihpu82 :  POSAS   :: 49.152    Days::
cmihpu82 :  ARTDAS  :: 34.176    Days::
cmihpu83 :  ARTDB   :: 11.386    Days::
talhpu27 :  A3TAS   :: 0.647     Days::
talhpu28 :  B3TAS   :: 0.646     Days::
cmihpu12 :  COMWP981:: 318.889   Days::
cmihpu12 :  COMWD981:: 339.943   Days::
cmihpu81 :  DVFLP981:: 456.457   Days::



Actually sort -rn workingg as expected. The problem with the file which has disorder in few columns that I was trying ,
Code:
sort -rnk 5

Code:
sort -rn file1
456.470
456.469
456.468
456.467
456.467
456.466
456.465
305.932
172.089
144.179
144.130
111.578
111.573
111.572
111.572
87.211
87.175
87.174
86.905
86.905
75.898
75.895
75.894
75.894
75.893
# uname -a
HP-UX srvhp004 B.11.23 U ia64 899690123 unlimited-user license



Thanks all.

Last edited by rveri; 07-10-2013 at 03:10 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

creating a fixed length output from a variable length input

Is there a command that sets a variable length? I have a input of a variable length field but my output for that field needs to be set to 32 char. Is there such a command? I am on a sun box running ksh Thanks (2 Replies)
Discussion started by: r1500
2 Replies

2. Shell Programming and Scripting

how to get rid of all chars after the last decimal points

Hi All, Here is my original string: 192.168.2.1.8088. The target string I want: 192.168.2.1, how can I use awk or sed or other command to get rid of .8088 in the string? Thanks, Ray (9 Replies)
Discussion started by: rluo
9 Replies

3. UNIX for Dummies Questions & Answers

accuracy of output - decimal points

Is there a way when using awk to specify the number of decimal points needed for the output? (2 Replies)
Discussion started by: cosmologist
2 Replies

4. Shell Programming and Scripting

Reducing the decimal points of numbers (3d coordinates) in a file; how to input data to e.g. Python

I have a file full of coordinates of the form: 37.68899917602539 58.07500076293945 57.79100036621094 The numbers don't always have the same number of decimal points. I need to reduce the decimal points of all the numbers (there are 128 rows of 3 numbers) to 2. I have tried to do this... (2 Replies)
Discussion started by: crunchgargoyle
2 Replies

5. Shell Programming and Scripting

Shell arithmetic : operations on decimal points

i am having a varialbe a , which is input to my file i want to multiply this input with value .43, and assign it to variable b. i tried it as below: #!/bin/sh a=$1 b=`expr $1\*0.43` echo b=$b error : expr: non-integer argument Please tell me , how to do this. Thanks (10 Replies)
Discussion started by: rishifrnds
10 Replies

6. UNIX for Dummies Questions & Answers

Help with decimal points

Hi All, I would like to set decimal point to 16 in the following bash script but it has syntax error at }: awk '{printf"%.16e", (a<500,a++,$1/(a*1.1212121212121229e-02))}' input.dat >output.datHow may I set it in the correct way please? Thank you very much! (6 Replies)
Discussion started by: sxiong
6 Replies

7. UNIX for Dummies Questions & Answers

How to control the decimal points for p-values in scientific format?

Dear all, I have a txt file with only one column which contains p values. My data looks like this: 5.04726976606584e-190 2.94065711152402e-189 2.94065711152402e-189 9.19932135717279e-176 1.09472516659859e-170 1.24974648916809e-170 0.1223974648916 0.9874974648916 ... what I want... (2 Replies)
Discussion started by: forevertl
2 Replies

8. Shell Programming and Scripting

Using awk to place decimal points at proper position

Hi, I have one input file which is delimited by pipe. I want to put decimal points in this input file at particular position in particular column and also get the negative sign (if any) at start of that column. $ cat Input_file.txt 11|10102693|1|20151202|10263204|20151127|N|0001... (7 Replies)
Discussion started by: Prathmesh
7 Replies

9. Shell Programming and Scripting

Convert variable length record to fixed length

Hi Team, I have an issue to split the file which is having special chracter(German Char) using awk command. I have a different length records in a file. I am separating the files based on the length using awk command. The command is working fine if the record is not having any... (7 Replies)
Discussion started by: Anthuvan
7 Replies

10. Homework & Coursework Questions

Grep commands for numbers w/decimal points

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Is there a grep commands for numbers w/decimal points Display lines for students with GPA above 3.69 but less... (3 Replies)
Discussion started by: jetoutant
3 Replies
dlasrt.f(3)							      LAPACK							       dlasrt.f(3)

NAME
dlasrt.f - SYNOPSIS
Functions/Subroutines subroutine dlasrt (ID, N, D, INFO) DLASRT Function/Subroutine Documentation subroutine dlasrt (characterID, integerN, double precision, dimension( * )D, integerINFO) DLASRT Purpose: Sort the numbers in D in increasing order (if ID = 'I') or in decreasing order (if ID = 'D' ). Use Quick Sort, reverting to Insertion sort on arrays of size <= 20. Dimension of STACK limits N to about 2**32. Parameters: ID ID is CHARACTER*1 = 'I': sort D in increasing order; = 'D': sort D in decreasing order. N N is INTEGER The length of the array D. D D is DOUBLE PRECISION array, dimension (N) On entry, the array to be sorted. On exit, D has been sorted into increasing order (D(1) <= ... <= D(N) ) or into decreasing order (D(1) >= ... >= D(N) ), depending on ID. INFO INFO is INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value Author: Univ. of Tennessee Univ. of California Berkeley Univ. of Colorado Denver NAG Ltd. Date: November 2011 Definition at line 89 of file dlasrt.f. Author Generated automatically by Doxygen for LAPACK from the source code. Version 3.4.1 Sun May 26 2013 dlasrt.f(3)
All times are GMT -4. The time now is 12:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy