sed and variable
Hi,
I've some problem with variables between my bash script and sed:
The script is invoked like:
script.sh my_file
Content of my_file:
blabla blabla blabla TopDesignName="old_pattern"
and i would like to have
blabla blabla blabla TopDesignName="new_pattern"
My bash script:
#!/bin/bash
NEW_PATTERN="new_pattern"
#I put the content of the last field ($NF) of the first record (NR<2) in #OLD_PATTERN variable (with " erased)
OLD_PATTERN=`awk -F "=" 'NR < 2 {print $NF} $1 | tr -d '\042'`
# and i want substitute the OLD_PATTERN by the NEW_PATTERN
cat $1 | sed "s/$OLD_PATTERN/NEW_PATTERN/" # don't work
#If I try
cat $1 | sed "s/old_pattern/NEW_PATTERN/" # work
So,I don't know how to pass the $OLD_PATTERN to sed ???
Thanks for your help
Philippe
|