Sponsored Content
Full Discussion: Sort by absolute value
Top Forums Shell Programming and Scripting Sort by absolute value Post 302559786 by sudvishw on Wednesday 28th of September 2011 06:25:42 AM
Old 09-28-2011
Sort by absolute value

Hi,
I have a file as follows:
Code:
  |-30.0|Appls. executing in db manager currently   = 2
  |-80.0|Locks held currently                       = 1
  | 90.0|High water mark (bytes)                 = 65536
  |-50.0|Configured size (bytes)                 = 16777216
  |-100.0|Current size (bytes)                    = 131072

I want to sort on the absolute value of the second column with '|' as delimeter. sort -n sorts the field numerically but cannot sort by its absolute value ignoring the signs.

I would like to get an output as follows:
Code:
  |-30.0|Appls. executing in db manager currently   = 2
  |-50.0|Configured size (bytes)                 = 16777216
  |-80.0|Locks held currently                       = 1
  | 90.0|High water mark (bytes)                 = 65536
  |-100.0|Current size (bytes)                    = 131072

Please help.

Thanks,
Sudha
 

9 More Discussions You Might Find Interesting

1. Programming

absolute path

How to find out the absolute path of a file in C/C++? Thanks (4 Replies)
Discussion started by: filedeliver
4 Replies

2. Shell Programming and Scripting

get absolute filename

How would I get the absolute filename of a selected file...I want to control click...I already have the context menu all set to run a script...I just need to be able to get the file name of the file I control clicked on. In windows it is as follows: set filename=%~f1 set name=%~n1 set... (0 Replies)
Discussion started by: mainegate
0 Replies

3. Shell Programming and Scripting

Absolute value

Is there a function in awk to get the absolute value of a-b which can be negative or positive, I just care for the absolute value... (5 Replies)
Discussion started by: placroix1
5 Replies

4. UNIX for Dummies Questions & Answers

absolute value

is there any function in unix which will convert a integer to absolute value with a single decimal point. suppose x=15232 y=x/1024=14.875 i want y to be 14.8 Similarly if y=6.29452 it should come as 6.3 (3 Replies)
Discussion started by: dr46014
3 Replies

5. Shell Programming and Scripting

How to Sort Floating Numbers Using the Sort Command?

Hi to all. I'm trying to sort this with the Unix command sort. user1:12345678:3.5:2.5:8:1:2:3 user2:12345679:4.5:3.5:8:1:3:2 user3:12345687:5.5:2.5:6:1:3:2 user4:12345670:5.5:2.5:5:3:2:1 user5:12345671:2.5:5.5:7:2:3:1 I need to get this: user3:12345687:5.5:2.5:6:1:3:2... (7 Replies)
Discussion started by: daniel.gbaena
7 Replies

6. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

7. Shell Programming and Scripting

Help with sort word and general numeric sort at the same time

Input file: 100%ABC2 3.44E-12 USA A2M%H02579 0E0 UK 100%ABC2 5.34E-8 UK 100%ABC2 3.25E-12 USA A2M%H02579 5E-45 UK Output file: 100%ABC2 3.44E-12 USA 100%ABC2 3.25E-12 USA 100%ABC2 5.34E-8 UK A2M%H02579 0E0 UK A2M%H02579 5E-45 UK Code try: sort -k1,1 -g -k2 -r input.txt... (2 Replies)
Discussion started by: perl_beginner
2 Replies

8. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

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. Shell Programming and Scripting

How to use absolute function?

Hello All, I am using following awk command in my shell script. I want to compare the value in column 2 and colum 3 after taking their absolute value. Column $2 and $3 can have any value positive or negative or both. awk -F"|" '{print $0,($2>$3?"F":"T")}' OFS='|' myfile.txt Your help... (2 Replies)
Discussion started by: angshuman
2 Replies
cachefswssize(1M)					  System Administration Commands					 cachefswssize(1M)

NAME
cachefswssize - determine working set size for cachefs SYNOPSIS
cachefswssize logfile DESCRIPTION
The cachefswssize command displays the workspace size determined from logfile. This includes the amount of cache space needed for each filesystem that was mounted under the cache, as well as a total. USAGE
See largefile(5) for the description of the behavior of cachefswssize when encountering files greater than or equal to 2 Gbyte ( 2 **31 bytes). EXAMPLES
Example 1: A sample output of cachefswssize. example% cachefswssize /var/tmp/samlog /home/sam end size: 10688k high water size: 10704k /foo end size: 128k high water size: 128k /usr/dist end size: 1472k high water size: 1472k total for cache initial size: 110960k end size: 12288k high water size: 12304k EXIT STATUS
The following exit values are returned: 0 success non-zero an error has occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
cachefslog(1M), cachefsstat(1M), cfsadmin(1M), attributes(5), largefile(5) DIAGNOSTICS
problems were encountered writing log file There were problems encountered when the kernel was writing the logfile. The most common problem is running out of disk space. invalid log file The logfile is not a valid logfile or was created with a newer version of Solaris than the one where cachefswssize is running. SunOS 5.10 16 Sep 1996 cachefswssize(1M)
All times are GMT -4. The time now is 05:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy