Hi,
Probably this is a out of scope of the thread. I have a requirement as below
I have a file with below content
CMD //DS > testfile
I have to replace
//DS
with a value which is assigned to a variable outside using awk gsub.
For example
var=TEST
I expect an output as
CMD TEST
I tried below 2 awk
awk '{gsub(/\/\/DS/,$var);print}' testfile
this fails
awk '{gsub(/\/\/DS/,"$var");print}' testfile
This doesn't replace the var value.
Could you please help me ?
---------- Post updated at 11:52 AM ---------- Previous update was at 11:31 AM ----------
I could accomplish this using sed as below
sed 's/\/\/DS/,'$var'/g' filename
Still looking for awk
Thanks