Hello I need to replace a string but i receive error using string 'return false;'
#!bin/bash
oldstring='{alert("bash")}'
newstring='{return false;}'
grep -rl $oldstring /home/commons.bundle.js | xargs sed -i s/$oldstring/$newstring/g
error: sh deleteBoo.sh sed: espressione -e #1, carattere 25: comando `s' non terminato
bash -x yourscriptmight help in some cases. Paste it at http://shellcheck.net to check for errors with automatic suggestions how to fix some problems. (Unfortunately shellcheck doesn't suggest to quote all variables.) – Bodo Feb 03 '21 at 17:24sedfromxargswith the output ofgrepwill likely not do what you want as the lines matching the expression given togrepwould be used as arguments, not input data, withsed. – Kusalananda Feb 03 '21 at 17:27-l. – Kusalananda Feb 04 '21 at 06:38