views:

26

answers:

0

how to replace a set of lines in a file with another set of lines in unix ?

#!/usr/bin/ksh
export text1='log_file=$LOG_PATH${UNISON_JOB}".log"'
export text2='\. \$\{env_path\}set_test_log_file\.ksh'
export text3='log_file\=\$LOG_PATH\$\{UNISON_JOB\}\"\.log\"'

echo $text1
echo $text2
echo $text3

for file in `grep -il ${text1} SANDEEP`
do
sed 's/${text3}/${text2}/g' $file > /$file.tmp
mv /$file.tmp $file
echo $file
done

i tried the above code but its not working . its kshell .here sandeep is the file name i m searching.