Given a parameter $1
, I want to subtract 5 minutes from that time, and echo it (later reuse the variable).
echo $1
time5=date -d "$1 5 minutes ago" +'%H:%M'
echo ${time5}
Call with: ./script.sh 16:55
Result:
prints 16:50
./script.sh: line 2: -d: command not found
Why can't I assign the date to the variable time5
?
You can use the
$()
operator for this: