Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hello, I have a file that has 3 columns and I want to make a numeric sort with third
column in ascending order.
the file of serious departure (file1).
1 TATE DANCER -12
2 STANISLESS 0
3 UN CAPO 7
4 BABIA -3
5 ZAGATO -2
6 ELDAMAR -10
7 ALABARDERO -7
8 DUDU -8.5
9 OCHO REALES 3
10 CARMENTA -2.5
11 ALBARREAL -6
12 ARNOIA -7
13 RIVALLERO -4
14 VAILLANT PRINCE 4
15 TORCAL -4.5
16 CASTROGONZALO -6
17 BEST SUPER -17
18 THE BREAKERS -13
19 KIZAS -2
20 DANS LES ETOILES-22.5
if I make the sort with these parameters it leaves mesort -r -k 1.29,1.32 file1
3 UN CAPO 7
14 VAILLANT PRINCE 4
9 OCHO REALES 3
2 STANISLESS 0
8 DUDU -8.5
7 ALABARDERO -7
12 ARNOIA -7
16 CASTROGONZALO -6
11 ALBARREAL -6
15 TORCAL -4.5
13 RIVALLERO -4
4 BABIA -3
20 DANS LES ETOILES-22.5
10 CARMENTA -2.5
5 ZAGATO -2
19 KIZAS -2
17 BEST SUPER -17
18 THE BREAKERS -13
1 TATE DANCER -12
6 ELDAMAR -10but I would want that this came out.
3 UN CAPO 7
14 VAILLANT PRINCE 4
9 OCHO REALES 3
2 STANISLESS 0
5 ZAGATO -2
19 KIZAS -2
10 CARMENTA -2.5
4 BABIA -3
13 RIVALLERO -4
15 TORCAL -4.5
16 CASTROGONZALO -6
11 ALBARREAL -6
7 ALABARDERO -7
12 ARNOIA -7
8 DUDU -8.5
6 ELDAMAR -10
1 TATE DANCER -12
18 THE BREAKERS -13
17 BEST SUPER -17
20 DANS LES ETOIL -22.5
that options should use in the sort?"La experiencia es algo maravilloso. Nos permite reconocer un error cada vez que lo volvemos a cometer.", Franklin P. Jones

First, if the field seperator is white space, your data file is NOT necessarily 3 columns. If the second column has a space like:
THE BREAKERS
this is actually two columns. I took your data file and placed an "X" in the offending places:
TATEXDANCER -12
2 STANISLESS 0
3 UNXCAPO 7
4 BABIA -3
5 ZAGATO -2
6 ELDAMAR -10
7 ALABARDERO -7
8 DUDU -8.5
9 OCHOXREALES 3
10 CARMENTA -2.5
11 ALBARREAL -6
12 ARNOIA -7
13 RIVALLERO -4
14 VAILLANTXPRINCE 4
15 TORCAL -4.5
16 CASTROGONZALO -6
17 BESTXSUPER -17
18 THEXBREAKERS -13
19 KIZAS -2
20 DANSXLESXETOILES -22.5Now, this command does the proper sort:
sort -n -r -k 3,3 datafile
This doesn't necessarily solve your problem given your data file.

A similar example:
# sort -k 2.7bn sort | sort -k 2.6bn | sort -k 2.5bn | sort -k 2.4bn
cluster_var dsk9g
cluster_home dsk10c
archive dsk13c
oracle9 dsk19c
oracle920 dsk20c
orascr dsk24h
root2_domain dsk50a
root1_domain dsk51a
sde9 dsk54c
oracle10g dsk55c
oracle8_RV0 dsk991c
sde9_RV0 dsk999c
archive_RV0 dsk1000c
oralogs_RV0 dsk1001c

![]() |
merge 2 files using perl
|
Script to find & dele...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |