Issue
I'm trying to substitute date
command in sed
.
As shown below, I'm trying boh command & variable substitution but neither of the approaches produce output. I've tried a few things of which I'm posting below the one that doesn't error out.
sed -n "/$(date -d '1 year ago' '+%Y-%m')/,$p" filename.csv
search=$(date -d "1 year ago" '+%Y-%m')
sed -ne '/"${search}"/,$p' filename.csv
How could I substitute either a variable or a command into sed
please?
Solution
sed -n '/'"$(date -d "1 year ago" '+%Y-%m')"'/,$p' filename.csv
Answered By - usert4jju7