Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In bash what does ! (exclamation mark) before command means?

I just mispelled command

git status

with

!git status

Console showed it started cloning last cloned repository into folder status...

My question is, what does this command mean and does it have any usage?

like image 776
JTC Avatar asked Feb 12 '18 13:02

JTC


People also ask

What does exclamation point mean in terminal?

A number following an exclamation point refers to an event. If that event is in the history list, the shell executes it. Otherwise, the shell displays an error message. A negative number following an exclamation point references an event relative to the current event. For example, the command !–

What does exclamation mark mean in Unix?

Sends a command to the Unix shell.

How do I escape exclamation mark in bash?

In addition to using single quotes for exclamations, in most shells you can also use a backslash \ to escape it.

Do commands take an exclamation mark?

Exclamation Marks Turn Requests Into Commands When an imperative sentence ends in a period, it's making a polite request or issuing an instruction.


Video Answer


1 Answers

In bash, if you type ! followed by a command name, it will substitute it with the last command in your history starting by that name.

So in your case !git was substituted with git clone somerepo so the whole line was translated to git clone somerepo status

like image 76
Axnyff Avatar answered Sep 22 '22 15:09

Axnyff