Summary of using the exclamation mark command (!) in Linux

Summary of using the exclamation mark command (!) in Linux

Preface

Recently, our company has configured mbp, and I use ssh more often. I am too lazy to write those complicated commands, so I searched for a command on the Internet and found it is more suitable for me.

The '!' symbol can not only be used as a negation symbol in Linux, but can also be used to retrieve commands from the historical command record or execute previously run commands without modification.

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

Exclamation mark command usage

Double exclamation mark!!

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

eg:
 $ ./startup.sh
 $ cat !!

This command is equivalent to cat ./startup.sh, eliminating the need to switch back and forth

!$

Represents the last parameter in the previous command

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

If the previous path is a long one, it will be very convenient.

!string

Represents the most recent command that begins with the specified string

eg:
 $ !ssh

Execute the most recent ssh command

!? string?

Similar to MySQL's fuzzy matching, execute the command containing the specified string in the most recent command

eg:
 $ !?ssh?

Execute the most recent command involving ssh

!n or !-n

This command is usually used with the history command.


Use history to find ssh records

eg:
 $ !109

Execute history to query the command with the previous sequence number 109

 $ !-1

Execute the command corresponding to the number obtained by subtracting 1 from the current command number

I just changed jobs recently and I'm quite busy, so the updates are quite slow.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • Summary of the unknown usage of "!" in Linux

<<:  Detailed steps for creating a Vue scaffolding project

>>:  Mysql 5.7.17 winx64 installation tutorial on win7

Recommend

Native js implementation of slider interval component

This article example shares the specific code of ...

Introduction to user management under Linux system

Table of contents 1. The significance of users an...

Processing ideas for decrypting WeChat applet packages on PC in node.js

Table of contents Where is the source code of the...

WiFi Development | Introduction to WiFi Wireless Technology

Table of contents Introduction to WiFi Wireless T...

JavaScript setinterval delay one second solution

When using setinterval, it is found that it will ...

Comprehensive website assessment solution

<br />Sometimes you may be asked questions l...

Implementation of Portals and Error Boundary Handling in React

Table of contents Portals Error Boundary Handling...

First experience of creating text with javascript Three.js

Table of contents Effect Start creating text Firs...

MySQL Series 4 SQL Syntax

Table of contents Tutorial Series 1. Introduction...

Detailed example of inserting custom HTML records in Quill editor

It is already 2020. Hungry humans are no longer s...

Instructions for using the meta viewport tag (mobile browsing zoom control)

When OP opens a web page with the current firmwar...

The neglected special effects of META tags (page transition effects)

Using js in web design can achieve many page effec...

CentOS IP connection network implementation process diagram

1. Log in to the system and enter the directory: ...

Implementing a random roll caller based on JavaScript

This article shares the specific code of JavaScri...