• 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: Command line text substitution
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: Command line text substitution


  • Subject: re: Command line text substitution
  • From: brian mather <email@hidden>
  • Date: Fri, 10 Jan 2003 23:56:52 -0500

From Paul Skinner:

>Ok, I'm trying to use the right tools. What's the right CL tool for
>replacing a string within a string? perl is an obvious choice. So, how
>would I replace a given string in another string using do shell script?
>--
>Paul Skinner


How about sed?

sed 's/string1/string2/' filename

Perl no doubt would work but I've no experience with it and have used sed to
meet my needs.

You can build a regular expression to find string 1 and then either
completely replace it with string2 or use back references to selectively
keep some parts while replacing others.

Could even build a quick 'for' loop to iterate thru files while using the
shell if that proves more convenient than to do so in your Applescript.

brian
_______________________________________________
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: Command line text substitution
      • From: John W Baxter <email@hidden>
  • Prev by Date: Re: Forcing 'tell app' to use carbon, rather than classic app/
  • Next by Date: safari printing?
  • Previous by thread: Re: Command line text substitution
  • Next by thread: re: Command line text substitution
  • Index(es):
    • Date
    • Thread