I am trying to run a script to replace a section of code in a lot of .php files. I need to replace:
`popupOpen(\'/home/open.php?c='.urlencode($row['id']).'&s=\', 650, 600)`
with this:
`popupOpen(\'/home/open.php?c='.urlencode($row['id']).'&s=\', 1024, 750)`
The command I am using is:
find . -name "index.php" -print | xargs sed -i "s/popupOpen(\\\'\/home\/open.php?c='.urlencode\($row\['id']\).'\&s=\\\', 650, 600)/popupOpen(\\\'\/home\/open.php?c='.urlencode\($row\['id']\).'\&s=\\\', 1024, 750)/g"
I just cant seem to escape it properly. What am I missing?
You can do without xargs
:
find .name "index.php" -exec sed -i '' sed "whatever" {} \;
and in this case I think this will work:
find . -name "index.php" -exec sed "s|popupOpen(\\\\'/home/open\.php\?c=\'\.urlencode(\\\$row\[\'id\'\])\.\'&s=\\\\', 650, 600)|popupOpen(\\\\'/home/open\.php\?c=\'\.urlencode(\\\$row\[\'id\'\])\.\'\&s=\\\\', 1024, 750)|g" {} \;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.