Re: SED in AS
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>) |