Operating System - HP-UX
1834394 Members
1555 Online
110066 Solutions
New Discussion

Re: sort numerically on second field

 
SOLVED
Go to solution
Bill McNAMARA_1
Honored Contributor

sort numerically on second field

output as follows,
OC-ISUP-ANSI 200110311815.39
OC-ISUP-ANSI-P352 200110311819.37
OC-SS7-AAA 200110311420.41
OC-SS7-AAA-P119 200110311422.15
OC-SS7-AAA-P122 200110311421.31
OC-SS7-P294 200110311754.10
OC-SS7-P396 200110311755.58
OC-TSC 200110311744.45
OC-TSC-P315 200110311814.33

how can I, with sort, list the output in a ascending numerical order.
as you can see, it's sorting alphabetically/numerically on the first field.

The command to produce this btw is:
# swlist -a install_date | grep OC

Thanks to Robin for that!

Later,
Bill
It works for me (tm)
4 REPLIES 4
Thierry Poels_1
Honored Contributor
Solution

Re: sort numerically on second field

hi,

swlist -a install_date | grep OC | sort -k2

;-)
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Santosh Nair_1
Honored Contributor

Re: sort numerically on second field

Technically, it should be

swlist -a install_date | grep OC | sort -n -k2

notice the -n which tells sort to order numerically rather then lexographically.

-Santosh
Life is what's happening while you're busy making other plans
Eugen Cocalea
Respected Contributor

Re: sort numerically on second field

Hi,

swlist -a install_date|grep OC|sort -k 2,2 -t '.'

E.
To Live Is To Learn
Eugen Cocalea
Respected Contributor

Re: sort numerically on second field

Hi again,

oopsie, I thought you want it on the second field of the date :)

The solution is:

swlist -a install_date|grep OC|sort -n -k2

E.
To Live Is To Learn