• 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: Reading files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading files


  • Subject: Re: Reading files
  • From: pete boardman <email@hidden>
  • Date: Wed, 19 Oct 2005 11:25:27 +0100

On 19 Oct 2005, at 09:54, Wayne Melrose wrote:

On Oct 19, 2005, at 10:33 AM, Shane Stanley wrote:

Reading every line of a long file takes a long time with applescript.

How long is a long file? If it's only a few megabytes, read it all and
extract the text from it in AS.

Wouldn't "cat", "tail" or "head" be better? for reading the contents of a file?

It does seem sensible to use the Unix tools for this, purely for speed. Here's 'sed':


--
set l to {11808, 175210} -- line numbers
set oldtid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "p;"
set l1 to l as text
set AppleScript's text item delimiters to oldtid
do shell script "sed -n '" & l1 & "p' /usr/share/dict/web2 "
--


Pete _______________________________________________ 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
  • Follow-Ups:
    • Re: Reading files
      • From: Shane Stanley <email@hidden>
References: 
 >Re: Reading files (From: Shane Stanley <email@hidden>)
 >Re: Reading files (From: Wayne Melrose <email@hidden>)

  • Prev by Date: Re: Reading files
  • Next by Date: Re: Reading files
  • Previous by thread: Re: Reading files
  • Next by thread: Re: Reading files
  • Index(es):
    • Date
    • Thread