• 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: do shell script "perl... " to find/replace in a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: do shell script "perl... " to find/replace in a string
      • From: Joseph Weaks <email@hidden>
References: 
 >do shell script "perl... " to find/replace in a string (From: Joseph Weaks <email@hidden>)

  • Prev by Date: Re: AC power testing
  • Next by Date: Re: osascript and Modification Date of Compiled Script
  • Previous by thread: do shell script "perl... " to find/replace in a string
  • Next by thread: Re: do shell script "perl... " to find/replace in a string
  • Index(es):
    • Date
    • Thread