Show History Command Time

Source: Internet
Author: User

The default in the history command is not to show the time, if we want to show the time when using the historical command can be done by setting environment variables.

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1430559272139140.png "alt=" 1.png "src=" http://www.178linux.com/ueditor/php/upload/image /20150502/1430559272139140.png "/>

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1430559307314911.png "alt=" 2.png "src=" http://www.178linux.com/ueditor/php/upload/image /20150502/1430559307314911.png "/>

The specific parameters of the Histtimeformat variable are similar to those in the date command, and can be modified on the date-time format of the parameter Date command.

But if the result of the history command is exported to a file, it looks like this:

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1430559645111484.png "alt=" 3.png "src=" http://www.178linux.com/ueditor/php/upload/image /20150502/1430559645111484.png "/>

The number shown in the figure indicates the number of seconds from the beginning of the Unix period to the execution of this command.

Let's convert the number in the file into a format we can read:

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1430560099996731.png "alt=" 3.png "src=" http://www.178linux.com/ueditor/php/upload/image /20150502/1430560099996731.png "/>

Again to beautify the format, now look. Bash_history displays the results in a row with dates and commands, and looks awkward, and then uses the awk command to get them on one line:

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1430560556644593.png "alt=" 4.png "src=" http://www.178linux.com/ueditor/php/upload/image /20150502/1430560556644593.png "/>

It's time to see the history command, but there are a few more questions:

1, the environment variable setting is temporary, after exiting the session will disappear;

2. format. bash_history file command too long, can't remember;

1, environment variables can be written in the/ETC/BASHRC file to ensure that each login is automatically loaded.

2, as for that very long command, originally I wanted to write the command alias, but the command alias for the definition of the command with "" is not supported, so the command is written into the script.

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px ; border-right:0px; "title=" 1430561930651336.png "alt=" 1.png "src=" http://www.178linux.com/ueditor/php/upload/ Image/20150502/1430561930651336.png "/>

650) this.width=650; "Style=" border-bottom:0px;border-left:0px;height:auto;vertical-align:middle;border-top:0px; border-right:0px; "title=" 1430562094808908.png "alt=" 2.png "src=" http://www.178linux.com/ueditor/php/upload/image /20150502/1430562094808908.png "/>


Show History Command Time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.