I have 3 files: en.json, en 1.json and en 2.json. All of them have the below content
{
"ABC" : "/long_name",
"DFG" : "/{long_name}"
}
I run below command to replace ABC with 123 and DFG with 456
grep -El 'ABC|DFG' *.json | xargs sed -ibak -e 's#ABC#123#g' -e 's#DFG#456#g'
text gets replaced in en.json but for en 1.json and en 2.json it fails with the below error
sed: en: No such file or directory
For some reason, the space is ignored and I am not sure how I can handle it within the command
grepwith-Z/--nullto use a null byte as delimiter, and pass-0/--nulltoxargsaswellgrep -Z -El 'ABC|DFG' *.json | xargs -0 sed -ibak -e 's#ABC#123#g' -e 's#DFG#456#g'. In other words, add-Zto the options you're using withgrep, and add-0as an option toxargs.