• 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: Passing Return-Delimited Text to UNIX Sort
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing Return-Delimited Text to UNIX Sort


  • Subject: Re: Passing Return-Delimited Text to UNIX Sort
  • From: Christopher Stone <email@hidden>
  • Date: Tue, 09 Jul 2013 05:10:58 -0500

On Jul 09, 2013, at 02:47, Rick Gordon <email@hidden> wrote:
BUT THEN I SAW:
... that if I added without altering line endings to the do shell script command that that wasn't necessary.
______________________________________________________________________

Hey Rick,

Using without altering line endings is very handy at times, but there is a pitfall:

set AppleScript's text item delimiters to return
set _var to quoted form of (characters of "zyx" as text)
set _sorted to paragraphs of (do shell script "echo " & _var & " | tr '\\r' '\\n' | sort" without altering line endings)
choose from list _sorted

You end up with a trailing linefeed, and this will produce an extra list item if you coerce to list.

Paragraphs is happy with either CRs or LFs of course, and on occasion it can be more convenient than fooling with TIDs.

You also know that when you get text back from a Unix command and use WALE that you'll have that last linefeed, so you can allow for it and use items 1 thru -2 of (paragraphs of <text>) if that makes more sense in your context.

So there's more than one way to do it.

--
Best Regards,
Chris

 _______________________________________________
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

References: 
 >Re: Passing Return-Delimited Text to UNIX Sort (From: Rick Gordon <email@hidden>)

  • Prev by Date: Re: Passing Return-Delimited Text to UNIX Sort
  • Next by Date: Re: Passing Return-Delimited Text to UNIX Sort
  • Previous by thread: Re: Passing Return-Delimited Text to UNIX Sort
  • Next by thread: Re: Passing Return-Delimited Text to UNIX Sort
  • Index(es):
    • Date
    • Thread