#!/bin/ksh
file_name=$1
old_templet=$2
new_templet=$3
# Loop through every file like this
for file in file_name
do
cat $file | sed “s/old_templet/new_templet/g” > $file.new
#do a global searce and replace and put the results
mv $file.new $file
#rename $file.new to original name of file
done
If you want to replace single pattern with a new pattern witn newline use following:
modify the sed part to
sed ‘s/old_template/new_templ1^Jnew_templ2^Jnew_templ3/’ tst
here the ^J
is then a ctrl-V and hit the return key, u ll c a ^J character
besides instead of doing the cat and redirecting to one file and then moving the new file to old u can do
perl -i -ne “s/old_template/new_templ1nnew_templ2nnew_templ3/” file1
file1 will be overwritten with the desired result , use the n instead of ^J in perl