• 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: SED in AS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SED in AS


  • Subject: Re: SED in AS
  • From: Christopher Stone <email@hidden>
  • Date: Tue, 16 Aug 2011 01:20:49 -0500

On Aug 15, 2011, at 23:19, Alex Zavatone wrote:
Just tried some SED command on an 8000+ line block of text.  AppleScript no likey.  
______________________________________________________________________

Hey Alex,

Yes there is an upper limit on text size for do shell script:

Technical Note TN2065:

How long can my command be? What’s the maximum number of characters?
There is no precise answer to this question. (See Gory Details for the reasons why.) However, the approximate answer is that a single command can be up to about 262,000 characters long — technically, 262,000 bytes, assuming one byte per character. Non-ASCII characters will use at least two bytes per character — see Dealing with Text for more details.

Will try to see what the max char size is or line size is for shell scripts.

Also - my attempt to remove the office legalese from my emails can has fail.  Might have to see if I can hack in a gmail somehow.  

I would probably use sed's in-place edit ability:

cd /Users/chris/test_directory/
sed -i '.bak' -E 's/t[^ ]+/•/g' sed_in_place.txt

The -i switch plus the extension specifier will edit the file in-place and create a backup in case you screw up.

This kind of limit is yet another reason why I commonly use the Satimage.osax for text processing.

# Using the Satimage.osax 'change' function in a custom handler

# Not quite 12,000 lines with 446 characters per line.
# 5.2 MB on disk

set f to alias "Thor:Users:chris:test_directory:sio_test.txt"

set seriousText to read f

cng("^Lorem.+", "•", f) # In-place edit.
--> 0.1396 seconds

set newText to cng("^Lorem.+", "•", seriousText) # Edit to variable
--> 0.1742 seconds

--
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: 
 >SED in AS (From: Alex Zavatone <email@hidden>)

  • Prev by Date: SED in AS
  • Next by Date: Re: Scrolling in Lion
  • Previous by thread: SED in AS
  • Next by thread: New Tab in Ribbon - Word 2011
  • Index(es):
    • Date
    • Thread