I got a text file a.txt like that:
start_date:{start_date};end_date:{end_date}
I want to replace {start_date} and {end_date} in shell script.
#!/bin/bash
START_DATE="2021-06-01"
END_DATE="2021-06-02"
awk '{gsub(/{start_date}/, '$START_DATE'); gsub(/{end_date}/, '$END_DATE');print $0 }' a.txt
I want to get something like:
start_date:2021-06-01,end_date:2021-06-02
But acutally I got:
start_date:start_date:2014;end_date:2013
It seems that the variable START_DATE and END_DATE was calcuated in script.It try to wrap variable with double quotes but also failed. How to escaped them in awk?