Background: I have multiple RTF files. I want to find and replace based on the following criteria: (1) Case sensitive find/replace (2) Include phrases with spaces between words (3) Using a find variable and a replace variable for the FIND and REPLACE (4) Doing a batch through a particular directory searching multiple RTF files.
I've tried with Sed -e, Sed -i, M4 and different Awk attempts. I finally had success with the following:
Code: Select all
echo "Enter Variable to Change (i.e. FIRMNAME ) Do Not Use: &"
read var222
echo "Enter Replacement Words (i.e. Charlie Inc. ) Do Not Use: &"
read repl111
for i in *.rtf; do
awk -v var="$var222" -v var2="$repl111" '{gsub ( var, var2 ) }; {print}' $i >/new/directory/"$i"
done
I hope someone can use this.
Best,
Slavvo67