我学习了一段时间的 shell 脚本,并决定重新创建 this question's 接受的答案,尽管我真的无法找到 DateTime
等价物在其中的表现。
如何获得 DateTime
命令? (关于Date time in Linux bash)
答案 0 :(得分:0)
您可以通过在声明变量时传递 date
参数来获取日期:
var=$(date '+%d/%m/%Y %H:%M:%S');
正如 @Cyrus 所指出的,您也不能通过以下方式使用 date
:
printf -v var "%(%d/%m/%Y %H:%M:%S)T\n" -1