Re: Rep: sort with do Shell script
Re: Rep: sort with do Shell script
- Subject: Re: Rep: sort with do Shell script
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 4 May 2010 20:05:45 -0400
Well, the sentinel can be any string, not just a single character. But apparently the limitation is in the size of the string you can pass to "do shell script". Which makes sense, since I'm sure that turns into a 'sh -c "command goes here"' which means that the whole thing is subject to the command line argument length restriction.
So I'm glad you got the Works solution working.
Another alternative would be to roll your own sort routine in AppleScript (someone linked to a qsort implementation on another thread).
But there is a straightforward shell solution: simply write the list out to a file and then sort that:
set sortedList to paragraphs of (do shell script "sort -n -u " & quoted form of POSIX path of someFile)
(The annoying part of that solution, IMO, is the actual writing to a file, which is just far more work in AS than it seems like it should be. open for access, set eof, aliases vs files vs file specifications vs furls...)
On Tue, May 4, 2010 at 5:07 PM, Yvan KOENIG
<email@hidden> wrote:
Le 4 mai 2010 à 22:36, Yvan KOENIG a écrit :
Le 4 mai 2010 à 22:09, Mark J. Reed a écrit :
The list is too long for the shell command line - it's the echo that's failing, before it ever gets to sort. Try this:
do shell script "sort -n -u <<EOF" & return & (unsortedList as text) & return & "EOF"
If one of the elements of the list might be "EOF", pick a different string for the sentinel...
Thanks.
With EOF same error.
As 10.4 accept ASCII character
I defined the variable sentinel
and edited the instruction as :
do shell script "sort -n -u <<" & sentinel & return & (unsortedList as text) & return & sentinel
I tried with
set sentinel to ASCII character (1)
…
set sentinel to ASCII character (7)
and always got the same result.
As there is no Unicode character, I will try to import the text in an AppleWorks spreadsheet.
Numbers is desesperately slow with such a list.
15 minutes aren't sufficient and after that my patience is gone.
Done
With AppleWorks plus one formula, I was able to sort and drop duplicates.
The coelacanthus is well and alive ;-)
Yvan KOENIG (VALLAURIS, France) mardi 4 mai 2010 22:47:52
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
--
Mark J. Reed <
email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden