Use history Command-history

Source: Internet
Author: User
Bash saves the history of commands used. The history of these commands is stored in the. bash_history file of the user's main directory.

Introduction

Bash saves the history of commands used. The history of these commands is stored in the. bash_history file in the user's main directory.

========================================================== ===

Search for history commands

You can run the following command to view the history content list:

[Root @ allyes20121031 de_info_center] # history | less

1 [13:59:13] cd/www/de_info_center

2 [13:59:14] ll

3 [13:59:59] cd ..

4 [14:00:02] cd de_info_center

5 [14:00:03] pwd

6 [14:16:58] ps-A | grep "de_info"

7 [14:17:01]./de_information_center

8 [14:17:11]./de_information_center start/www/de_info_center/de_information_center_config.txt

9 [14:17:14]./de_information_center

(END)

========================================================== ===

Use! Row number

Assume that the command 2 [13:59:14] ll is found. We can use it! 2, to quickly use the command for this line.

[Root @ allyes20121031 de_info_center] #! 2

Ll

Total 2660344

-Rw-r -- 1 root 2594 May 15 13:05 argv. cpp

-Rw-r -- 1 root 1296 May 14 argv. h

-Rw-r -- 1 root 5001 May 13 config. cpp

-Rw-r -- 1 root 5382 May 13 13:56 config. h

========================================================== ===

More history extensions

!! : Repeat The Last Command.

! Row number: execute the command line n in the record.

! String: repeat the recent historical commands starting with string.

!? String: repeat recent historical commands that contain strings.

Related Article

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.