Update 20170114 Set Date and Time for Each Command You Execute in Bash History.md

This commit is contained in:
Hymantin 2017-01-19 17:04:28 +08:00 committed by GitHub
parent 355ada6986
commit b6c49f20e1

View File

@ -23,24 +23,25 @@ The date and time associated with each history entry can be written to the h
There are two possible ways of doing this: one does it temporarily while the other makes it permanent.
这里有两种可行的方式来达到目的:一种是暂时的效果,一种是永久的效果。
To set HISTTIMEFORMAT variable temporarily, export it as below on the command line:
为了设置 HISTTIMEFORMAT 读变量,输入以下指令:
为了设置 HISTTIMEFORMAT 读变量,输入以下指令:
```
$ export HISTTIMEFORMAT='%F %T'
```
In the export command above, the time stamp format:
在上面的输出指令当中,时间戳格式:
1. `%F`  expands to full date same, as %Y-%m-%d (year-month-date).
2. `%T`  expands to time; same as %H:%M:%S (hour:minute:seconds).
Read through the [date command][4] man page for additional usage information:
1.  `%F`  expands to full date same, as %Y-%m-%d (year-month-date).
1.F拓展至完整日期就像Ymd
2.  `%T`  expands to time; same as %H:%M:%S (hour:minute:seconds).
2.T拓展日期就像HMS
Read through the [date command][4] man page for additional usage information:通读[时间指令][4]操作说明来获得更多使用说明:
```
$ man date
```
Then check your command history as follows:
Then check your command history as follows:然后如下检查你的指令历史
```
$ history
```
@ -48,29 +49,27 @@ $ history
![Display Linux Command History with Date and Time](http://www.tecmint.com/wp-content/uploads/2017/01/Set-Date-and-Time-on-Linux-Commands-History.png)
][5]
Display Linux Command History with Date and Time
Display Linux Command History with Date and Time显示带有日期和时间的 Linux 指令历史。
However, if you want to configure this variable permanently, open the file `~/.bashrc` with your favorite editor:
However, if you want to configure this variable permanently, open the file `~/.bashrc` with your favorite editor:然而,如果你想将变量配置成永久的,用你最喜欢的编辑器打开文件 `~/.bashrc`
```
$ vi ~/.bashrc
```
And add the line below in it (you mark it with a comment as your own configuration):
And add the line below in it (you mark it with a comment as your own configuration):然后在下方添加(你用注释标记为自己的配置):
```
#my config
export HISTTIMEFORMAT='%F %T'
```
Save the file and exit, afterwards, run the command below to effect the changes made to the file:
保存文件并退出,然后,运行改变过的指令:
```
$ source ~/.bashrc
```
Thats all! Do share with us any interesting history command tips and tricks or your thoughts about this guide via the comment section below.
Thats all! Do share with us any interesting history command tips and tricks or your thoughts about this guide via the comment section below.就是这些!请通过下方的评论区来与我们分享一些有趣的历史指令的小技巧以及你对这份说明的想法。
--------------------------------------------------------------------------------
作者简介:
@ -78,13 +77,13 @@ Thats all! Do share with us any interesting history command tips and tricks o
![](http://1.gravatar.com/avatar/7badddbc53297b2e8ed7011cf45df0c0?s=128&d=blank&r=g)
I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+
我是 Ravi SaiveTecMint 的创建者。一个爱在网上分享的技巧和提示的电脑极客和 Linux 专家。我的服务器在 Linux 开放资源平台的大部分。请在 Twitter, Facebook 和 Google 等上关注我。
--------------------------------------------------------------------------------
via: http://www.tecmint.com/display-linux-command-history-with-date-and-time/
作者:[Ravi Saive][a]
译者:[译者ID](https://github.com/译者ID)
译者:[Hymantin](https://github.com/Hymantin)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出