[英]Bash: How to pass a variable to a command
I need to substract 10 minutes from a given time.我需要从给定时间减去 10 分钟。
As I understand from previous answers, there are solutions only for given constant input, for example:正如我从以前的答案中了解到的那样,只有给定的恒定输入才有解决方案,例如:
date --date '20140202 11:45:30 UTC -10 min'
But in my script, a given date is read from file and I have it as argument, for example:但是在我的脚本中,从文件中读取给定的日期并将其作为参数,例如:
myDate="20140202 11:45:30"
How can I pass this argument (myDate)
to the command above?如何将此参数
(myDate)
传递给上面的命令?
myDate="20140202 11:45:30"
date --date "${myDate} UTC -10 min"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.