CentOS uses all the parameters of the previous command in detail

  
        

Reducing keyboard input can greatly improve the productivity of programmers. The use of shortcut keys is a good example. Programmers often use terminals. So is there a similar "shortcut" on the terminal that can improve our efficiency? The programmer's work is often related to before and after. So, this article will demonstrate how to use the previous command to increase productivity.

1.Use all the parameters of the previous command

Method:!*

Example: If I edited hello.txt and bye.txt, then I want to use Git add adds these two files. You can use: git add !*

2. Use the last parameter of the previous command

Method:!$

ALT + .

ESC + .

The latter two methods, the terminal will automatically complete

3. Use the last command except the last parameter part

Method: !-:

Example: Personally think this is useful, because some commands will input a lot of options in the middle, and the last one is the actual working object. If you enter the option again, it will be troublesome.

4. Use any part of the previous command

Method: ALT + + .

where num represents the first part of the previous command, from 0 Start with ls -shld hello.txt. ALT +0+. is ls. 1 is -shld

5. Replace one part of the previous command

Method: Replace foo with bar

^foo^bar Replace only one

!!:gs/foo/bar Replace all

6. Previous command

Method:!!

More: We often run a lot of very Long command, this time, you can view the command through history, and then use ! (history command number).

Copyright © Windows knowledge All Rights Reserved