I have a big list of php files that need a hardcoded path changed So let's say I want to change /mydir/file.php to /yourdir/file.php, in all the .php files under /home/mydomains/ There must be an easy one-line way using grep or find in UNIX, could anyone suggest it please?
I know it isn't what you asked. You can do it under windows using multi-replace. The downside is you have to add all the files to the list.
Thanks but I have linux and 78 websites on which I'd like to change that one line, so I have no other options :/ After some searching I've tried the following: find /home/admin/domains/mydomain.com/public_html/ -type f | xargs perl -pi -e 's/include\(\'\.\.\/inc\/stuff\.php\'\);/include\(\'\/mylibs\/stuff\.php\'\);/g' When I use it in SSH though, I get a prompt (??) that apparently is waiting for my input..any idea? The escapes seem to be ok
try: find /home/admin/domains/mydomain.com/public_html/ -type f | xargs perl -pi -e "s/include\(\'\.\.\/inc\/stuff\.php\'\);/include\(\'\/mylibs\/stuff\.php\'\);/g"
Hey stumbled on this while googling what I was trying to do. I need to do the same thing but having "issues" I need to do a find and replace in all ascii files in the current directory and recursively through the sub directories I need to replace </body> with </body><test string here> but when I try running find -type f | xargs perl -pi -e "</body>\s+;</body><test\s+string\s+here>'\);/g" I get: Backslash found where operator expected at -e line 1, near "</body>\" (Missing operator before \?) Bareword found where operator expected at -e line 1, near "s+;</body><test\s+string\s+here" syntax error at -e line 1, near "</body>\" Can't find string terminator "'" anywhere before EOF at -e line 1.
Actually just found the answer myself find /testdir -type f -exec sed -i 's#</body>#</body><string for you>#g' {} \; works like a champ