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 |
Do you have to use a script and do you have to use sed?
awk -F= '{print$1"=new_pattern"}' file.txt > file1.txt |
Hi,
I think i have to use because the variable OLD_PATTERN is never the same,may be there is an easy solution Thanks homey |
All times are GMT -5. The time now is 03:34 AM. |