Re: sort question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Roberto Ragusa wrote:
> jack craig wrote:
>> On 03/09/2010 04:32 PM, adrian kok wrote:
>>> I have file as below
>>>
>>> 192.168.0.4      switch
>>> 192.168.0.47    server 
>>> 192.168.0.43    printer
>>> 192.168.0.218  fax
>>> 192.168.0.205  monitor
>>>
>>> How can I use sort to 
>>>
>>> 192.168.0.4   switch
>>> 192.168.0.43  printer
>>> 192.168.0.47  server
>>>
>> sort -nr < file1 > file2
>>
>> doesnt work?
> 
> sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n
> 
It's because the implementation of sort only applies -n to one field. So it has 
to be restated for each field, as above. I would think this is a bug, I swear I 
used to sort IP addresses without all this effort using the old SysV sort 
command. In any case, this is the sort we have, it doesn't handle numeric sort 
with -n or -g very well, but we live with it.

If I think of it I'll test the bsd sort the next time I'm on one one.

Demo case:
  sort -n <<ABC
  10 10
  10 4
  4 10
  10 4
  y 10
  x 10
  y 4
  x 4
  ABC

Only the first field is evaluated numerically.

-- 
Bill Davidsen <davidsen@xxxxxxx>
   "We have more to fear from the bungling of the incompetent than from
the machinations of the wicked."  - from Slashdot
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux