6 methods of executing historical commands in linux bash

Many times when we use the Linux command line, we need to find the used commands.

At this time, you usually like to use the up and down arrow keys or the history command to find the previously used command.

In this article, I’d like to share with you some quick search history command methods that you don’t know.

6 methods of executing historical commands
  • !!
    repeat the previous command
  • !t
    repeat the previous command headed by t
  • !Number
    repeat the previous command with number in the history table
  • !-Number
    repeat the history table countdown number command
  • !$
    gets the last option in the previous command
  • Ctrl + R
    use Ctrl + R to enter the history search mode to query a past command in the history table. After finding the command to be repeated, press enter to execute the command

Examples

skill -1

Like the above command, you can see that I typed !! . Actually, I repeated the last command ls.

skill -2

As the above command, you can see that three rm commands have been typed, and input !r, which matches the last rm -rf t3.log command.

skill -3

With the above command, history sees the number of history. Typed !6532 to execute ll with the number 6532.

skill -4

skill -5

skill –6

Add a Comment

Your email address will not be published. Required fields are marked *