Timeline for How to search and replace text in all php-files in a directory and its subdirectories
Current License: CC BY-SA 4.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| S Dec 17, 2020 at 15:19 | history | edited | thanasisp | CC BY-SA 4.0 | Otherwise shell expansion won't work - Note: I kept only double quotes and will add this to the next answer, where its a comment. |
| S Dec 17, 2020 at 15:19 | history | suggested | ᴍᴇʜᴏᴠ | CC BY-SA 4.0 | Otherwise shell expansion won't work |
| Dec 17, 2020 at 10:48 | review | Suggested edits | |||
| S Dec 17, 2020 at 15:19 | |||||
| Jan 17, 2012 at 13:53 | vote | accept | clamp | ||
| Jan 17, 2012 at 10:33 | comment | added | Coren | $ is used by bash for variables. you'll need to escape it with a '\'. | |
| Jan 17, 2012 at 10:22 | comment | added | clamp | 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? | |
| Jan 17, 2012 at 10:16 | history | edited | Coren | CC BY-SA 3.0 | added 188 characters in body |
| Jan 17, 2012 at 10:15 | comment | added | Coren | you can use an other character than '/' in sed. For instance, sed -i -e "|$pattern|$replacement|g works well | |
| Jan 17, 2012 at 10:06 | comment | added | clamp | thank you! the only problem remaining is that the pattern contains forward slashes which seem to be problematic in the regexp | |
| Jan 17, 2012 at 10:04 | comment | added | Coren | 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" | |
| Jan 17, 2012 at 9:52 | comment | added | clamp | ok thank you! same question here: how would i load the search pattern from a file? | |
| Jan 17, 2012 at 9:40 | history | answered | Coren | CC BY-SA 3.0 |