• 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: 'sort' command-alternative?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'sort' command-alternative?


  • Subject: Re: 'sort' command-alternative?
  • From: John Delacour <email@hidden>
  • Date: Thu, 3 Oct 2002 23:22:55 +0100
  • Mac-eudora-version: 5.3 alpha

At 2:31 pm -0400 3/10/02, Rips Ethan J wrote:

b. if there's an alternative, such as a sort command in a shell script that
can be called by Applescript.


Here's a script that returns a sorted list of the the names of running processes. You can adapt it to any use. You can also sort by number with a slight addition.


tell app "Finder" to set ls to name of processes
set AppleScript's text item delimiters to {return}
set ls to ls as string -- turn the list into paragraphs
set AppleScript's text item delimiters to {""}
do shell script "perl -e '
$return = qq(\\015) ;
$list = qq(" & ls & ") ;
@array = split /$return/, $list;
for (sort @array) { print qq($_$return) } '"
paragraphs of result


-- JD
_______________________________________________
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:
    • Re: 'sort' command-alternative?
      • From: bill fancher <email@hidden>
    • Re: 'sort' command-alternative?
      • From: Rob Jorgensen <email@hidden>
References: 
 >'sort' command-alternative? (From: "Rips Ethan J" <email@hidden>)

  • Prev by Date: 'System Events.app' won't get processes in Classic under 10.2
  • Next by Date: Re: Regex on OS X
  • Previous by thread: 'sort' command-alternative?
  • Next by thread: Re: 'sort' command-alternative?
  • Index(es):
    • Date
    • Thread