I am trying to convert a user input to datetime value but it gives invalid date error in shell script
start_time=$5' '$6
start_time=$(date --date='$start_time')
$5 the user is entering 03/12/2015 $6 the user is entering 00:10:00
I am trying to convert a user input to datetime value but it gives invalid date error in shell script
start_time=$5' '$6
start_time=$(date --date='$start_time')
$5 the user is entering 03/12/2015 $6 the user is entering 00:10:00
Variable expansion/substitution doesn't happen with single quotes. So in :
start_time=$(date --date='$start_time')
$start_time
is not substituted with its content.
However, when you use double quotes variables are first substituted before doing anything with the resultant string. So do :
start_time=$(date --date="$start_time")