History Command parsing

Source: Internet
Author: User

View history Commands

History #显示所有历史命令history #显示最近的10条命令

To view the number of default history command bars:

Echo $HISTSIZE

This environment variable is defined in/etc/profile.

LS!407 # re-calls a positive number in history No. 407 command command LS!-4 #重新调用历史中的倒数第4条命令

Historical commands are stored in two parts:. Bash_history and Memory

When you exit normally, the in-memory history is stored in the. bash_history

Executes the first last command starting with shut

!shut

Execute the previous command containing go

!? Go
    • Execute the command you just executed

1: Up and down key turn 2:ctrl+p3:!! 4:! -1
    • Search executed command:

Ctrl+r
    • Using Parameters

Use parameters from several commands that you have just executed, but the commands are different: (Take the command LS for example)

ls esc.      #按完ESC, press directly after loosening. ls alt+.ls !^   # The first parameter of the previous command ls !$    #表示上一个命令的最后一个参数ls  !:2   #调用上一个命令中的第二个参数ls  !*     #调用上一个命令中的所有参数ls  !444:2    #调用history中第444个命令的第2个参数ls  !444:*     #调用第444个命令中的所有参数 

The Alt method is not useful in the non-host and screen

    • Clear all History

history -c           #清除内存中的命令历史rm  ./bash_history     #删除历史文件中的内容HISTSIZE =0          #  Clears the memory history by modifying the history command bar number 
    • Other options

history [-c][-d offset]history -a|n|r|w [filename]history -p|s arg [arg  ... ]history -d num   #删除指定的条目history  -a   #强制内存中的history追加到./bash history -n   #常用于多用户登陆 in the _history file, loading the contents of the history file that have not been loaded into the history list history -r  #  read from .bash_history reads the history -w   #将当前内存中的历史, appends to the specified file, and defaults to. Bash_ historyhistory -p rm -rf /   #只显示命令, not added to the history list history -s rm - rf /   #不显示命令, but adds the command to the history list 

history-p & History-s

[[email protected] wu]# history-p rm-rf m rm-rfm[[email protected] wu]# History 3 262 ls-d * 263 ll-d * hist Ory 3[[email protected] wu]# history-s rm-rf/[[email protected] wu]# History 3 3 265 rm-rf/266 Tory 3


History Command parsing

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.