Dav*_*vid 2 shell timestamp ubuntu-10.04
我经常发现自己需要在文本文件中输入时间戳。有没有办法将当前时间戳快速插入到 Ubuntu 中的文件中?
您可以使用该date
命令。
date >> my_file.txt
Run Code Online (Sandbox Code Playgroud)
my_file.txt
要将时间戳放入的文件在哪里。
查看strftime(3)
( man 3 strftime
)的手册页以查看您可以使用的一些日期格式化程序。例如:
date +%l:%M >> my_file.txt
Run Code Online (Sandbox Code Playgroud)
将输出类似9:37
(Hour:Minute) 到文本文件。