I'm trying to write a script that basically works like Microsoft words find>replace function. It first asks for two inputs from the user. First one for strings to be found and the second one for strings to replace the old ones. Even though this is pretty straight forward, I also want to count the number of things to be replaced and echo the user to confirms these specific number of replacements. How can I do that? So far I have this as the search>replace function:
for file in
find -name '*.sdf.new'
;
do
grep "$search" $file &> /dev/null
sed -i "s/$search/$replace/" $file
done