Re: 'sort' command-alternative?
Re: 'sort' command-alternative?
- Subject: Re: 'sort' command-alternative?
- From: bill fancher <email@hidden>
- Date: Thu, 3 Oct 2002 16:49:07 -0700
On Thursday, October 3, 2002, at 03:22 PM, John Delacour wrote:
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
Or you could be a heretical minimalist and just use:
set text item delimiters to (ASCII character 10)
tell application "Finder" to set theList to (name of processes) as
string
set text item delimiters to {""}
do shell script ("echo '" & theList & "'| sort")
(Hope Larry doesn't issue a fatwah.)
For docs on sort, run:
do shell script("man sort|col -b")
--
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.