In my script, the following code successfully produces a timestamp variable for $n in the format 2016-04-28T15:47:48
for n in $(perl parsetime.pl | sed "s/.....$//") do echo $n
However, I now want to use this variable to calculate the time 15 minutes earlier. Someone else provided me the syntax to produce the timestamp in the correct format (which worked)-this was achieved like this:
/opt/bin/date --date '-15 minutes 2016-04-28T15:39:27' "+%Y-%m-%dT%H:%I:%S"
However, my issue is now, when I try to use the $n variable instead of writing out the actual timestamp I get the message like this I get an error message.
for n in $(perl parsetime.pl | sed "s/.....$//") do /opt/bin/date --date '-15 minutes "$n"' "+%Y-%m-%dT%H:%I:%S"
/opt/bin/date: invalid date `-15 minutes "$n"
What am I doing wrong? How can I incorporate the $n variable into the code correclty?