“sed” replace date in text file with current date

We want to call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below:

abc.txt
------------------
Code:
line1
line2
line3
$$EDWS_DATE_INSERT=08-27-2019
line4
$$EDWS_PREV_DATE_INSERT=08-26-2019

I am trying to write a small command that can update these dates daily with current date but its not replacing the date value.
Code:

sed -i 's/$$EDWS_DATE_INSERT =.*/$$EDWS_DATE_INSERT="$(date `+%y%m%d`)"/' abc.txt

Current result:

$$EDWS_DATE_INSERT="$(date `+%y%m%d`)"

Can anyone help with this?

sed -i 's/$$EDWS_DATE_INSERT *=.*/$$EDWS_DATE_INSERT='"$(date "+%y%m%d")"'/' abc.txt
1 Like

sed -i 's/$$EDWS_DATE_INSERT *=.*/$$EDWS_DATE_INSERT='"$(date `+%y%m%d`)"'/' abc.txt

-ksh: +%y%m%d: not found [No Such File or directory]

gave this error but it worked ; however the date format ended up being timestamp its did not format to date

Code:
line1
line2
line3
$$EDWS_DATE_INSERT=Tue Aug 27 15:15:15 CDT 2019
line4

See updated post to fix quotes.

1 Like