History command: history, history command history

Source: Internet
Author: User

History command: history, history command history

[Root @ linux ~] # History [n]
[Root @ linux ~] # History [-c]
[Root @ linux ~] # History [-raw] histfiles
N: Number, which indicates "List of the nearest n commands!
-C: removes all history content in the current shell.
-A: adds the newly added history command to histfiles. If histfiles is not added, it is written to ~ by default ~ /. Bash_history
-R: Read the content of histfiles to the history Memory of the current shell;
-W: Write the Current history Memory to histfiles!
Example 1: List all history memories in the current Memory
[Root @ linux ~] # History
# Omitted earlier
1017 man bash
1018 ll
1019 history
1020 history
# The information listed is divided into two columns. The first column shows the code of this command in this shell,
# The other is the instruction content! As for how many Command records will be displayed, it is related to HISTSIZE!
Example 2: List the latest 3 Documents
[Root @ linux ~] # History 3
1019 history
1020 history
1021 history 3
Example 3: immediately write the current data to histfile
[Root @ linux ~] # History-w
# The historical records are written to ~ by default ~ /. Bash_history!
[Root @ linux ~] # Echo $ HISTSIZE
We can use related functions to execute commands! For example:
[Root @ linux ~] #! Number
[Root @ linux ~] #! Command
[Root @ linux ~] #!!
Number: indicates the number of commands executed;
Command: the nearest command searches for the command starting with "command" and executes the command;
!! : Execute the previous command (equivalent to pressing Enter after pressing the keys)
[Root @ linux ~] # History
66 man rm
67 alias
68 man history
69 history
[Root @ linux ~] #! 66 <= execute 66th commands
[Root @ linux ~] #!! <= Execute the previous command. In this example, it is! 66
[Root @ linux ~] #! Al <= execute the latest commands starting with al (the first 67th commands listed above)

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.