Whenever I run a command in bash CLI, I get the right output
date +%Y%-m%d%j%M%S
202111063103528
However, when I run this in a bash script, I am not getting a simple number that I can use in a later variable. I'm ultimately wanting to use this to backup old CSV files I've generated. e.g.
#Doesn't print out correct date
DATE='date +%Y%-m%d%j%M%S'
echo $DATE
# Ultimately, wanting to feed that $DATE string here
if [ -f "$CSV_OUTFILE" ]; then
echo "CSV file already exists. Renaming $CSV_OUTFILE to $CSV_OUTFILE.$DATE"
mv $CSV_OUTFILE $CSV_OUTFILE.$DATE
exit 1
fi