linux Bang Bang

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Linux !!

This command is also pronounced as 'bang bang' command. It repeats the last typed command in your shell.

Syntax:

!! 

Linux Bang Bang1

Look t the above snapshot, 'ls' command is repeated by passing '!!' command. After that, 'echo command will be repeated' has also repeated.


!

This command is pronounced as one bang. Last typed command will be repeated by '!!'. But, if you want to repeat other commands then you can use '!' command followed by one or more characters of that command.

Syntax:

!<characters> 

Linux Bang Bang2

Look at the above snapshot, command "!fi" repeats the above command 'file office'.


!n

Here, n denotes a number. Just type '!' followed by the command line number you want to use and that command will be executed.

Syntax:

  1. !<lineNumber>  

Example:

  1. !1043  

Linux Bang Bang3

Look at the above snapshot, we have executed command 'ls' from the line number 1043.