MACSCRPT Archives

May 2010

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Mark J. Reed" <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Mon, 10 May 2010 13:46:26 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (63 lines)
More like this, to replace the "five" instead of appending:

set oldTIDs to text item delimiters
set text item delimeters to "five"
set textList to text items of myText
set text item delimeters to (read myFile)
set newText to textList as text
set text item delimiters to oldTIDs

However, that's a global replace, not just the first instance.

On Monday, May 10, 2010, Stockly, Ed <[log in to unmask]> wrote:
> Something like this?:
>
> ------
> set myFile to choose file with prompt "Select an XML file"
> set myText to "one:two:three:four:five:"
>
> set newText to myText & (read myFile)
>
> ---------
>
> HTH,
>
> ES
>
>
> On 5/10/10 6:38 AM, "jeff donovan" <[log in to unmask]> wrote:
>
>> Greetings
>>
>> i need to add the contents of a file to the end of each line of a string. It
>> would be easy to do a simple sed 's/mytext/newtext/g'
>>
>> newtext in this case is an xml file. which needs to stay intact.
>>
>> my text looks like this
>>
>> one:two:three:four:five:
>>
>>
>> output needs to look like this
>>
>>
>> one:two:three:four: <?xml version="1.0" encoding="UTF-8"?>\
>> <dict>\
>> <key>AccountState</key>\
>> <string>Enabled</string>\
>> </dict>\
>>
>>
>> So I thought i could ;
>> REPLACE=/path/to/myfile
>> cat mytext | sed 's/five/$REPLACE/g'
>>
>>
>> im getting stuck any assistance would be helpful.
>> -j
>

-- 
Mark J. Reed <[log in to unmask]>

ATOM RSS1 RSS2