Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我的代码:
# Generate Datetime FILENAME="date +%Y%m%d%H%M%S" # Dump Database dumpdb FILENAME # Upload to S3 python uploaddb.py FILENAME
我担心的是我想继续引用“FILENAME”变量,除非该变量每秒都会改变它的值。如何将 FILENAME 的值设置为当前日期时间,然后将其保持在相同的值以提醒脚本,以便 FILENAME 始终引用相同的值。
要date在变量值中获取命令的输出,请编写:
date
FILENAME="$(date +%Y%m%d%H%M%S)"
$FILENAME
FILENAME