• 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: Bill <email@hidden>
  • Date: Sun, 21 Dec 2003 00:23:01 +0800

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"


-- original data
24.47.176.225
180.248.136.220
61.116.186.110
205.158.62.24
217.81.172.103
0.57.7.195
24.203.237.101
62.78.76.79
202.156.235.48
214.240.46.232
24.31.170.237
16.208.21.156
24.203.237.101
62.78.76.79
69.84.204.85
217.117.136.154
166.78.247.22
202.175.98.191
63.138.247.187
4.176.70.236

-- result in sortedIP.txt
0.57.7.195
4.176.70.236
16.208.21.156
24.203.237.101
24.203.237.101
24.31.170.237
24.47.176.225
61.116.186.110
62.78.76.79
62.78.76.79
63.138.247.187
69.84.204.85
166.78.247.22
180.248.136.220
202.156.235.48
202.175.98.191
205.158.62.24
214.240.46.232
217.117.136.154
217.81.172.103

bill

PS: [OT] unicode, Mail.app & mail server testing

b0b7b5b2
B+raw eventB;
B+f*e
e7%gf4;e B;
_______________________________________________
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:
    • Sorting IP addresses - Progress
      • From: Marconi <email@hidden>
    • Re: Sorting IP addresses
      • From: Emmanuel <email@hidden>
    • Re: Sorting IP addresses
      • From: Marconi <email@hidden>
  • Prev by Date: Re: change from upper to lower case
  • Next by Date: Re: Sorting IP addresses
  • Previous by thread: Re: Sorting IP addresses
  • Next by thread: Re: Sorting IP addresses
  • Index(es):
    • Date
    • Thread