Re: Sorting IP addresses
Re: Sorting IP addresses
- Subject: Re: Sorting IP addresses
- From: Marconi <email@hidden>
- Date: Sat, 20 Dec 2003 09:42:06 -0700
At 12:23 AM +0800 12/21/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"
Note that it only sorts the first quad. See the result beginning at '24..."
>
>
-- 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
_______________________________________________
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.