Sort help on non numeric field

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sort help on non numeric field
# 8  
Old 06-18-2011
Originally Posted by yazu
@ygemici Wow! Really great! Smilie

But maybe Perl is a little simpler:
% cat testfile| perl -F"," -alne 'push @V, [$F[0], $_];
        END { print $_->[1] for sort {$a->[0] cmp $b->[0]} @V}' 

you can use also perl of course Smilie and you dont need `cat`.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Sort by second column numeric values

From googling and reading man pages I figured out this sorts the first column by numeric values. sort -g -k 1,1 Why does the -n option not work? The man pages were a bit confusing. And what if I want to sort the second column numerically? I haven't been able to figure that out. The file... (7 Replies)
Discussion started by: cokedude
7 Replies

2. 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

3. Shell Programming and Scripting

[Solved] sort on numeric part of field

I have ran into a heavy case of PEBCAK*) and could need some advice on what i do wrong: OS is Linux (kernel 2.6.35), sort --version reports "8.5" from 2010, shell is ksh. Originally i had a file with with the following structure: hdisk1 yyy hdisk2 yyy hdisk3 yyy hdisk4 yyy hdisk5 yyy... (2 Replies)
Discussion started by: bakunin
2 Replies

4. Shell Programming and Scripting

Sort numeric order

Hi I am using this cat substitutionFeats.txt | gawk '{$0=gensub(/\t/,"blabla",1);print}' | gawk '{print length, $0}' | sort -n | sort -r and the "sort -n" command doesn't work as expected: it leads to a wrong ordering: 64 Adjustable cuffs 64 Abrasion- 64 Abrasion pas 647 Sanitized 647... (4 Replies)
Discussion started by: louisJ
4 Replies

5. UNIX for Dummies Questions & Answers

sort files by numeric filename

dear all, i have .dat files named as: 34.dat 2.dat 16.dat 107.dat i would like to sort them by their filenames as: 2.dat 16.dat 34.dat 107.dat i have tried numerous combinations of sort and ls command (in vain) to obtain : 107.dat 16.dat 2.dat 34.dat (1 Reply)
Discussion started by: chen.xiao.po
1 Replies

6. Shell Programming and Scripting

Perl script to sort data on second numeric field

Hi, I'm a learner of PERL programming. I've a input file with the below data: SWAT_5, 1703, 2010-09-21 SWAT_6, 2345, 2010-09-21 SWAT_7, 1792, 2010-09-21 SWAT_8, 1662, 2010-09-21 SWAT_9, 1888, 2010-09-21 VXHARP_1, 171, 2010-09-21 I need to sort this data based on the second... (6 Replies)
Discussion started by: ganapati
6 Replies

7. Linux

Using sort command to get numeric ascending order

HI everyone, I am trying to use the unix sort command to get a list of numbers sorted in ascending order but having trouble in getting it to work. An example of this issue would be when i am trying to sort the following three number each on a different line "1" , "2" and "116" the sort command... (3 Replies)
Discussion started by: wali4813
3 Replies

8. Shell Programming and Scripting

Sort alpha on 1st field, numerical on 2nd field (sci notation)

I want to sort alphabetically on the first field and sort in descending numerical order on the 2nd field. With a normal "sort -r -n" it does this: abc ||| 5e-05 ||| bla abc ||| 3 ||| ble def ||| 1 ||| abc def ||| 0.2 ||| def As you can see it ignores the fact that 5e-05 is actually 0.00005... (1 Reply)
Discussion started by: FrancoisCN
1 Replies

9. Shell Programming and Scripting

Numeric sort error

Hello all I have data like below where the column with values (PRI, SEC ) is the char field and the rest are Numeric Fields. 200707,9580,58,7,2,1,PRI,1,1,137,205594,0,5,10,-45.51,-45.51 200707,9580,58,7,2,1,SEC,1,1,137,205594,0,5,10,-45.51,45.51... (1 Reply)
Discussion started by: vasuarjula
1 Replies

10. Shell Programming and Scripting

how to numeric sort on field time

i want to sort time field given by who command as a whole i have tried like this who|sort -n +4 -5 (1 Reply)
Discussion started by: rahulspatil_111
1 Replies
Login or Register to Ask a Question
bup-margin(1)						      General Commands Manual						     bup-margin(1)

bup-margin - figure out your deduplication safety margin SYNOPSIS
bup margin [options...] DESCRIPTION
bup margin iterates through all objects in your bup repository, calculating the largest number of prefix bits shared between any two entries. This number, n, identifies the longest subset of SHA-1 you could use and still encounter a collision between your object ids. For example, one system that was tested had a collection of 11 million objects (70 GB), and bup margin returned 45. That means a 46-bit hash would be sufficient to avoid all collisions among that set of objects; each object in that repository could be uniquely identified by its first 46 bits. The number of bits needed seems to increase by about 1 or 2 for every doubling of the number of objects. Since SHA-1 hashes have 160 bits, that leaves 115 bits of margin. Of course, because SHA-1 hashes are essentially random, it's theoretically possible to use many more bits with far fewer objects. If you're paranoid about the possibility of SHA-1 collisions, you can monitor your repository by running bup margin occasionally to see if you're getting dangerously close to 160 bits. OPTIONS
--predict Guess the offset into each index file where a particular object will appear, and report the maximum deviation of the correct answer from the guess. This is potentially useful for tuning an interpolation search algorithm. --ignore-midx don't use .midx files, use only .idx files. This is only really useful when used with --predict. EXAMPLE
$ bup margin Reading indexes: 100.00% (1612581/1612581), done. 40 40 matching prefix bits 1.94 bits per doubling 120 bits (61.86 doublings) remaining 4.19338e+18 times larger is possible Everyone on earth could have 625878182 data sets like yours, all in one repository, and we would expect 1 object collision. $ bup margin --predict PackIdxList: using 1 index. Reading indexes: 100.00% (1612581/1612581), done. 915 of 1612581 (0.057%) SEE ALSO
bup-midx(1), bup-save(1) BUP
Part of the bup(1) suite. AUTHORS
Avery Pennarun <>. Bup unknown- bup-margin(1)

Featured Tech Videos