简体   繁体   中英

Bash: How to pass a variable to a command

I need to substract 10 minutes from a given time.

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="20140202 11:45:30"
date --date "${myDate} UTC -10 min"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM