I am trying to print the day of the week of a specified date. This command works very well:
TARGET=$(date -u -d'2015-10-25' '+%u')
But there is an error inside my bash script, what should be wrong?
day=25
month=10
year=2015
command1='date -u -d'
command3=''\'
command2=$year-$month-$day
fullcommand=$command1$command3$command2$command3' '$command3'+%u'$command3
echo $fullcommand
TARGET=$($fullcommand)
echo $TARGET
An error occurred:
date: the argument ‘'+%u'’ lacks a leading '+';
user3053231
source
share