Get the App
SLTechnology News&Howtos  ›  Servers  › 

Summary of the use of exclamation point command (!) in linux

Shulou Source: shulou.com Published: 2022-06-02 01:56:18 09月30日 Update

Preface

Recently, the company configured mbp, usually used more ssh, is really too lazy to write those complex commands, found a command on the Internet, feel more suitable for themselves.

'!' Symbols can be used not only as negative symbols in Linux, but also to retrieve commands from historical command records or to run commands before execution without modification.

The following article will give you a detailed introduction to the use of the linux exclamation mark command (!). Let's take a look at the detailed introduction.

Exclamation mark command usin

Double exclamation point!

!! Represents the last command entered and can be combined with other commands to form a new command

Eg: $. / startup.sh $cat!

This command is equivalent to cat. / startup.sh, eliminating switching back and forth

! $

Represents the last parameter in the previous command

Eg: $ls / usr/local/dic $cat! $/ a.txt

If the last path is very long, it will be very convenient.

! String

Represents the most recent command that begins with a specified string

Eg: $! ssh

Execute the most recent ssh command

!? String?

Similar to mysql's fuzzy matching, execute the most recent command that contains the specified string

Eg: $!? ssh?

Execute the most recent command that contains ssh

! n or!-n

This command is usually used with the history command

Use history to find ssh records

Eg: $! 109

Execute the history query to find out the previous command with serial number 109

$!-1

Execute the command corresponding to the current command sequence number minus one obtained sequence number

Recently, job-hopping is relatively busy, and the update is relatively slow.

Summary

The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.

Tags: Commands characters strings exclamation marks representatives serial numbers content symbols articles previous learning complexity slowness convenience value usage company preface history parameters Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Tech Info Xiaomi NVidia Shulou Technology