Re: Sorting IP addresses
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.