Following the bash -hakers wiki recommendation , I want to edit files using ed.
In particular, I want to do the following with ed instead of sed:
find . -type f -exec sed -i -e 's/a/b/g' {} \;
I see that ed doesn't have a choice of sed -e, as far as I know, feeds and forwarding are the only way to work with it non-interactively.
So, using ed from a bash script to do the same as the previous sed command would look like this:
ed file_name <<<$'g/a/s//b/g\nw'
or
echo $'g/a/s//b/g\nw' | ed file_name
But as far as I know, it is not possible to use pipes or io redirects in find -exec.
Did I miss something? or is the only way to overcome this is to use loops?
for file in $(find . -type f -print); do ed $file <<<$'g/a/s//b/g\nw'; done;
source
share