• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sorting IP addresses
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting IP addresses


  • Subject: Re: Sorting IP addresses
  • From: Graff <email@hidden>
  • Date: Sat, 20 Dec 2003 15:46:43 -0500

This will do it, it seems that you need to assign a start and an end to the keys:
sort -n -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n ~/Desktop/unsortedIP.txt -o ~/Desktop/sortedIP.txt

- Ken

On Dec 20, 2003, at 1:52 PM, Deivy Petrescu wrote:

At 6:05 PM +0100 12/20/03, Emmanuel wrote:
At 12:23 AM +0800 21/12/03, Bill wrote:
Marconi,

An alternative: using the shell command "sort".

Suppose a file records IP addresses, each in a new paragraph, with unix line ending, then you may try this one:

-- choose the file
set tmpPOSIX to quoted form of POSIX path of (choose file)
-- brief explanation: using . as field seperator, sort field 0-3 numerically
-- the first field is field 0, output the result to a file named "sortedIP.txt" on your desktop
>do shell script "sort -t. +0n +1n +2n +3n " & tmpPOSIX & " > ~/Desktop/sortedIP.txt"

And you say that only now? :-)

Thanks for that one!
Emmanuel

I have not received the original message.
As Marconi, I did not get the command to sort all four fields in numerical order.
If it does work, a better way to write it is

do shell script "sort -t. +0n +1n +2n +3n ~/Desktop/sortedIP.txt -o ~/Desktop/sortedIP.txt"

The "-o" option allows the system to do its dirty trick under the hood.
If anybody managed to get all 4 fileds sorted this way, could I get a message please?
Thanks
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Sorting IP addresses
      • From: Deivy Petrescu <email@hidden>
References: 
 >Re: Sorting IP addresses (From: Bill <email@hidden>)
 >Re: Sorting IP addresses (From: Emmanuel <email@hidden>)
 >Re: Sorting IP addresses (From: Deivy Petrescu <email@hidden>)

  • Prev by Date: Re: Make new folder with icon from image?
  • Next by Date: Move an item dropped into a folder & launch an app
  • Previous by thread: Re: Sorting IP addresses
  • Next by thread: Re: Sorting IP addresses
  • Index(es):
    • Date
    • Thread