I can replace text with the following command:
for f in $(ls some/dir); do sed 's/XXX/YYY/g' template.$f.txt; done
But when I try to use in-place replacement I fail:
sed: 1: "template.test00.types ...": undefined label 'emplate.test00.types.txt'
What am I doing wrong?
EDIT: Here is a complete minimal example:
for f in $(ls some/dir); do echo $f && cat -n some/dir/$f; done
a.txt
1 path: XXX/725
b.txt
1 path: XXX/615
c.txt
1 path: XXX/931
Here is how sed
works correctly without actual replacement:
for f in $(ls some/dir); do sed 's/XXX/YYY/g' some/dir/$f; done
path: YYY/725
path: YYY/615
path: YYY/931
And here is the failure:
for f in $(ls some/dir); do sed -i 's/XXX/YYY/g' some/dir/$f; done
sed: 1: "some/dir/a.txt": unterminated substitute pattern
sed: 1: "some/dir/b.txt": unterminated substitute pattern
sed: 1: "some/dir/c.txt": unterminated substitute pattern