I have a question related to awk command in shell. We have a input csv file with following values:
Control_Time;Report_Name
2020-08-10;Report A
2020-06-10;Report B
2020-07-01;Report C
My goal is to check all the rows in this file and filter (copy) only the rows which have a date greater than first day of previous month. So, I created an variable called previous_month which is following:
previous_month=$(date -d "`date +%Y%m01` -1 month" +%Y-%m-%d)
This variable works fine, but I am not able to work with it in awk statement which I want to use for filtering data into the output file.
I tried following statement just for printing the previous_month and it is not working.
awk -v previous_month="$(date -d "`date +%Y%m01` -1 month" +%Y-%m-%d)" '{print previous_month}'
However, echo previous_month works fine and it gives me the value 2020-07-01. Is there any way how to work with this custom variable? Thank you for all advices!