I want to add a variable for the results from the formula of one variable and results of another var

Good morning all,

This is the file name in question OD_Orders_2019-02-19.csv

I am trying to create a bash script to read into files with yesterdays date on the file name while retaining the rest of the files name. I would like for $y to equal, the name of the file with a formula output with the exact date in the middle. So far this is what I have:

To get yesterdays date in the correct format, I made x:

x="date -d yesterday +%Y-%m-%d"

y="OD_Orders_$x.csv"

This issue with this is that the results when I do a echo $y gives me this: OD_Orders_date -d yesterday +%Y-%m-%d.csv

Can someone please tell me how I can show the value of $x when echo $y correctly without it showing the formula? I need $y to input the filename with yesterdays date in the correct format because I want to use it more later on within this script.

x=$(date -d yesterday +%Y-%m-%d)

1 Like

If you want to reuse only $y , not $x , then you could also use

y="OD_Orders_$(date -d yesterday +%Y-%m-%d).csv"
1 Like