如何使用bash命令输出不带冒号的日期

时间:2018-11-20 07:00:36

标签: bash date command

我要输出以下内容:

命令:

  

日期+%T *

01:49:14

但是如何在没有冒号的情况下显示它呢?有什么想法吗?我正在使用bash命令。

2 个答案:

答案 0 :(得分:4)

当我做man date时,我得到了:

  

%T时间;与%H:%M:%S

相同

那么,为什么不这样做,它会提供与%T中的date选项相同的输出,而不是将%T与外部或bash工具一起使用来获得不同形式的结果:

date +"%H-%M-%S"
OR
date +"%H/%M/%S"
OR
date +%H%M%S       ##Without any output delimiter

答案 1 :(得分:-1)

怎么样?

date +%T | sed -e "s/:/ /g"