Hi, All:
Although we can do pattern match and corresponding substitution in Awk and Sed, I find it very disable when we want to do value-substitution.I mean:say, when I want to replace the words which equal to the value of $var1(say,$var1="charlie", we want to replace where it is charlie to daniel,here $var2=daniel) in file "file_test1",and we can't know what string to replace because var1,var2 is dynamically assigned value.How to do such "value-substitution"??? e.g.:
sed 's/$var1/$var2/g' file_test1
this will fully disobey what we want it to do!!!it will do pure pattern substitution,$var1--->$var2, but we want it to replace all "charlie" ---->"daniel".
PLEASE TELL ME HOW TO SOLVE SUCH A PROBLEM???We have to do such work in our work, THIS IS IN VERY URGENT NEED!!!!
help,please.
Although we can do pattern match and corresponding substitution in Awk and Sed, I find it very disable when we want to do value-substitution.I mean:say, when I want to replace the words which equal to the value of $var1(say,$var1="charlie", we want to replace where it is charlie to daniel,here $var2=daniel) in file "file_test1",and we can't know what string to replace because var1,var2 is dynamically assigned value.How to do such "value-substitution"??? e.g.:
sed 's/$var1/$var2/g' file_test1
this will fully disobey what we want it to do!!!it will do pure pattern substitution,$var1--->$var2, but we want it to replace all "charlie" ---->"daniel".
PLEASE TELL ME HOW TO SOLVE SUCH A PROBLEM???We have to do such work in our work, THIS IS IN VERY URGENT NEED!!!!
help,please.