• 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: do shell script "sort" not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do shell script "sort" not working


  • Subject: Re: do shell script "sort" not working
  • From: Martin Orpen <email@hidden>
  • Date: Tue, 08 Nov 2005 23:43:35 +0000
  • Thread-topic: do shell script "sort" not working

on 8/11/05 20:12, Chris Tangora at email@hidden wrote:

> set sort_script to ("sort -o " & Imagessorted_POSIX & " " & ImagesUsed_POSIX)
> do shell script sort_script

If you've got serious amounts of data from which you need to remove
duplicates then you might be better off using a more powerful tool like awk.

I posted a script that does this kind of thing a some time ago. Search the
archives for my name and "awk" & "seen" - I'd do it myself, but my web
access is crap at the moment :(

Another option might be using objective-c and nsarray's *distinct* method:

<http://www.idea-digital.com/applescript/objc/page24/nsarray.html>

Which works wonders with numbers, but needs a little of help to sort
strings:


set theList to {}
repeat 100 times
    set myletters to "abc"
    set tempList to {}
    repeat 4 times
        set end of tempList to some item of myletters
    end repeat
    set end of theList to tempList as string
end repeat

set foo to procArray(theList)
set AppleScript's text item delimiters to ASCII character 10
set bar to do shell script "echo " & quoted form of (foo as string) & " |
sort"
set AppleScript's text item delimiters to {""}
(count of foo) & return & bar

on procArray(myArray)
    tell application "Automator"
        set theArray to call method "arrayWithArray:" of class "NSArray"
with parameter myArray
        set sArray to call method "distinct" of myArray
    end tell
end procArray


I don't know if it is supposed to be used in this way as I only discovered
it by tinkering. But it seems to get the job done whenever I call it.

Regards

--
Martin Orpen


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: do shell script "sort" not working
      • From: Bruce Robertson <email@hidden>
References: 
 >do shell script "sort" not working (From: Chris Tangora <email@hidden>)

  • Prev by Date: Re: osacompile
  • Next by Date: Re: New FireFox 1.5 browser -- applescript implementation
  • Previous by thread: Re: do shell script "sort" not working
  • Next by thread: Re: do shell script "sort" not working
  • Index(es):
    • Date
    • Thread