Using ed to manipulate files matched by find
- by TheOsp
Following the bash-hackers wiki's 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 opt like sed's -e, so as far as I know, pipes and io redirections are the only way to work with it non-interactively.
So, using ed from a bash script to do the same as the above sed command would look like:
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 impossible to involve pipes or io redirections within find's -exec.
Do 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;