Re: do shell script "sort" not working
Re: do shell script "sort" not working
- Subject: Re: do shell script "sort" not working
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 8 Nov 2005 16:16:30 -0500
On 11/8/05,
Chris Tangora <
email@hidden> wrote:
I
am working on a script that makes a list of names. Using the
write command in AS I get a file named UnsortedImages.log containing
all the names I need. I would like to get the list sorted using
"sort" so that I can run a "uniq" after and get a list without
repetitive names. I've tried this both as a list and as a string
with returns in it. I then try to do a shell script of 'sort' and
it just doesn't work! Can someone take a look and tell me if
there is something I am missing?
1. Make sure that the file has *linefeeds* (ascii character 10)
not carriage returns (ascii character 13). Otherwise sort
will see it as one long line, which clearly cannot be sorted any more
than it already is.
2. You don't need to pipe the output of sort through uniq if all you
need is unique lines; there's a -u option to sort that causes it
to do the uniquing for you (e.g. "sort -u -o sortedfile
unsortedfile"). But if you want to do something fancier, like
keep count of how many repetitions there are for each line (uniq -c),
you still have to do it separately.
Thanks in advance.
set RootFileFolder to
("HardDrive:Users:User:Scripts:PDF_Image_Counter")
set ImagesUsed_log to
(RootFileFolder & ":ImagesUsed.log") as
string
set
ImagesUsed_POSIX to POSIX path
of ImagesUsed_log
set
ImagesSorted_log to (
RootFileFolder & ":ImagesSorted.log") as string
set Imagessorted_POSIX
to POSIX path of
ImagesSorted_log
set sort_script to ("sort -o " & Imagessorted_POSIX & " " & ImagesUsed_POSIX)
do shell script sort_script
If someone wants the rest of the script, just let me know...
Chris Tangora
Daytona Beach News-Journal
386.681.2748
chris.tangora <at> news-jrnl <dot> com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (
--
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:
This email sent to email@hidden