CentOS uses all parameters of the previous command

Time:2019-12-9

Reducing keyboard input can greatly improve the working efficiency of programmers. The use of shortcut keys is a good example. Programmers often use terminals. So is there a similar “shortcut key” on the terminal that can improve our efficiency? The work of programmers is often contextual. Therefore, this article will show you how to use the previous command to improve your work efficiency.

1. Use all parameters of the previous command

Method:!

Example: if I edit hello.txt and bye.txt, then I want to add them using git add. You can use: git add*

2. Use the last parameter of the previous command

Method:!

ALT + .

ESC + .

The latter two methods will be completed automatically in terminal

3. Use the part of the last command except the last parameter

Method:! –

Example: I think this is more useful, because some commands will input a lot of options in the middle, and the last one is the object that actually works. If you input options again, it will be troublesome.

4. Use any part of the previous command

Methods: Alt + < num > +

Where num represents the last part of the command, starting from 0, for LS – shld hello.txt. Alt + 0 +. Is ls. The 1 is -shld.

5. Replace a part of the previous command

Method: replace foo with bar

^Foo ^ bar only one

!: GS / foo / bar replace all

6. Last order

Method:!!

More: we often run a lot of long commands. At this time, you can view the commands through history, and then use! (command number in History).