• 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: Selecting Last X Lines of Shell Script Result
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Selecting Last X Lines of Shell Script Result


  • Subject: Re: Selecting Last X Lines of Shell Script Result
  • From: "Nigel Garvey" <email@hidden>
  • Date: Tue, 27 May 2008 11:07:01 +0100

Michelle Steiner wrote on Mon, 26 May 2008 13:21:12 -0700:

>On May 26, 2008, at 1:01 PM, Marconi wrote:
>
>> When executing a shell script, how do I set the my_Message variable
>> to just the last X lines of the output?
>
>
>Assume that you want the last fifteen lines.
>
>set my_Message to (do shell script "ls -l /Applications")
>set my_Message to paragraphs -1 through -15 of my_Message
>set text item delimiters to return
>set my_Message to my_Message as text
>display dialog my_Message

Just to be finicky:

  set my_Message to (do shell script "ls -l /Applications")
  set my_Message to text from paragraph -15 to -1 of my_Message

Surprisingly, this is a trifle faster on my machine than Craig's all-
shell suggestion.

NG


 _______________________________________________
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

  • Prev by Date: count paragraphs in file
  • Next by Date: Re: Checking files on remotes help
  • Previous by thread: Re: Selecting Last X Lines of Shell Script Result
  • Next by thread: Applescript and Cocoa and XCode
  • Index(es):
    • Date
    • Thread