Re: Native AS or grep via do shell script?
Re: Native AS or grep via do shell script?
- Subject: Re: Native AS or grep via do shell script?
- From: Jeremy Reichman <email@hidden>
- Date: Sun, 31 Oct 2004 21:03:10 -0500
On 10/31/04 12:17 AM, "Joseph Weaks" <email@hidden> wrote:
> Do we really need to read a whole Perl intro to learn how to use it for
> text manipulation in do shell script calls? I want to be able to write
> for myself these kinds of handlers that will take a string or an alias
> using calls to Perl:
>
> replaceFirstOccurrence(theString, toFind, toReplace)
>
> replaceEveryOccurence(theString, toFind, toReplace)
>
> replaceTextBetweenTwoStrings((theString, theStart, theEnd, toReplace)
>
> returnListOfEveryStringBetweenTheseTwoTags(theString, theStart, theEnd,
> toReplace)
>
> I'd like to learn Perl's Reg Ex enough to write lines that will find
> more dynamic matches, as well.
> What should I be reading to reach the goal?
Joe,
For text manipulation on a line by line basis, you may just want to use
'sed' rather than Perl. It's quite similar in some respects (the syntax is
like vi's or Perl's), and may not have quite the overhead of Perl for a
simple string search/replace*, yet can still do grep.
I actually just blogged about this the other day, for my own reference.
<http://www.jaharmi.com/2004/10/25>
I'll have to check out the satimage.osax. Sounds cool, from other bits of
this thread. Still wish grep were built-in to AppleScript, though.
* Others may disagree, of course. I'm a complete Perl novice, but I can
muddle through. If I were doing search/replace *within* a file (line by line
or across lines), I'm fairly certain I would use Perl based on the fun I've
had with it so far. But then again, I'd probably be doing either a shell or
Perl script to begin with, in that case ...
--
Jeremy
_______________________________________________
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