Re: do shell script "perl... " to find/replace in a string
Re: do shell script "perl... " to find/replace in a string
- Subject: Re: do shell script "perl... " to find/replace in a string
- From: Gnarlodious <email@hidden>
- Date: Wed, 17 Mar 2004 10:15:15 -0700
Entity Joseph Weaks spoke thus:
>
Given three variables, what would be a one liner do shell
>
script command that replaced every occurrence of findString in
>
sourceText with replaceString?
>
Not sure perl is the correct unix command to use for this.
set find to "findString"
set replace to return & "replaceString"
do shell script "perl -i -p -e 's/" & find & "/" & replace & "/' " &
TestFile
For simple line by line S&R, sed is easier:
do shell script "sed -e 's|search|replace|' " & TestFile
>
Secondly, is it possible to pass a unicode hex number as the
>
replaceString?
There's a UNIX shell command for this,
try -- iconv first
do shell script "iconv -f macintosh -t utf-8
sourcefile>targetfile"
on error -- maybe piconv is available?
do shell script "piconv -f MacRoman -t utf-8
sourcefile>targetfile"
end try
-- Gnarlie's Applescript page
http://www.Gnarlodious.com/OSX/AppleScript/AppleScript.html
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.