更具体地说,我希望将 Unix 时间戳附加到我的文件名中:
db:backup --database=mysql --destination=s3 --destinationPath=date+random.sql --compression=gzip
Run Code Online (Sandbox Code Playgroud)
但是,这给了我“date+random.sql”作为文件名,这不是我想要的。
使用该$( ... )构造创建...替换命令的文本输出;就像在...
--destinationPath="$(date)"+random.sql
Run Code Online (Sandbox Code Playgroud)
但请注意,标准日期格式不太适合时间戳,因此您通常会定义更合适的格式,例如..
--destinationPath=$(date +%Y%m%d%H%M%S)+random.sql
Run Code Online (Sandbox Code Playgroud)