• 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: Terminal grep from AS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Terminal grep from AS


  • Subject: Re: Terminal grep from AS
  • From: Christopher Nebel <email@hidden>
  • Date: Thu, 27 Jan 2005 17:07:56 -0800

On Jan 27, 2005, at 1:23 PM, Adam K. Wuellner wrote:

On Jan 27, 2005, at 1:55 PM, Goran Ehn wrote:
Sorry if I was a bit unclear before, here is a short sample. I just want to replace the Satimage grep and use the terminal grep instead, that is to strip the code off and get the text into lists one block at the time. --> {"This is ","a part ","of the test text."} -->{"This is","another text part."}
I'm somewhat unfamiliar with the possibilities when using 'do shell script', and I just want a sample of how I can pass the grep command + string and retrieve the result.
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<root>
<block id="1">
<text>This is </text><text>a part </text><text>of the test text.</text>
</block>
<block id="2">
<text>This is</text><text> another text part.</text>
</block>
</root>
AFAIK, grep can only return whole lines containing the pattern to be searched for, with or without the filename and line number, OR a count of the number of matches. I do not think it can be made to return the portion of a line that the pattern actually matched.

This is true, but it simply means that you should use something other than grep(1), not that you can't use "do shell script". However, since you appear to be dealing with XML, you should probably look at using an XML-specific package such as Late Night's XML Tools (or one of the several others I'm forgetting at the moment). You then wouldn't have any trouble handling this:


<block id="1"><text>blah</text><text>blah</text><text>blah</text></block>

...versus this:

<block id="1">
    <text>blah</text>
    <text>blah</text>
    <text>blah</text>
</block>


--Chris Nebel AppleScript Engineering

_______________________________________________
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: Terminal grep from AS
      • From: Goran Ehn <email@hidden>
References: 
 >Terminal grep from AS (From: Goran Ehn <email@hidden>)
 >Re: Terminal grep from AS (From: daniel <email@hidden>)
 >Re: Terminal grep from AS (From: Goran Ehn <email@hidden>)
 >Re: Terminal grep from AS (From: "Adam K. Wuellner" <email@hidden>)

  • Prev by Date: Localize weekdays
  • Next by Date: Re: syntax problem for reading an xml file in a bundle
  • Previous by thread: Re: Terminal grep from AS
  • Next by thread: Re: Terminal grep from AS
  • Index(es):
    • Date
    • Thread