i have command like this
date -d @$(date -d 'Sat, 08 Aug 2020 00:00:00' "+%s") +'%Y-%m-%d'
which output this
2020-08-08
So i want to use thins in bash scrip, i created this (this is just part of realy big script)
Date1=$1
date -d @$(date -d $Date1 "+%s") +'%Y-%m-%d'
But when i try to run like this
./test.sh "Sat, 08 Aug 2020 00:00:00"
I get
date: extra operand ‘Aug’
Try 'date --help' for more information.
date: invalid date ‘@’
So its look like that "" desapear when passing argument
$Date1
. Otherwise, it will be expanded asdate -d Sat, 08 Aug 2020 00:00:00 "+%s"
, which is not what you want. – annahri Oct 09 '20 at 08:58