Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • ok thank you! same question here: how would i load the search pattern from a file? Commented Jan 17, 2012 at 9:52
  • 1
    something like this, maybe ? pattern=cat /path/to/pattern; replacement=cat /path/to/replacement; find . -name "*.php" | xargs -n 1 sed -i -e "s/$pattern/$replacement/g" Commented Jan 17, 2012 at 10:04
  • thank you! the only problem remaining is that the pattern contains forward slashes which seem to be problematic in the regexp Commented Jan 17, 2012 at 10:06
  • 1
    you can use an other character than '/' in sed. For instance, sed -i -e "|$pattern|$replacement|g works well Commented Jan 17, 2012 at 10:15
  • thank you! now it runs without errors but it doesnt seem to replace anything. i guess the search pattern is not found. (although it is there). the search pattern contains all kind of characters including tabs, spaces, $, <, > etc. could that be the problem? Commented Jan 17, 2012 at 10:22