In case you did not know, exclamation marks play an essential position within the bash workflow, particularly on your command historical past!
okay… let me clarify this bizarre factor, truly it is easy :
-
The primary a part of the command will take the primary command merchandise from the second most up-to-date command you wrote, then concatenate to “add” and the second merchandise of the newest command,
git add second_folder
. -
For the second half, it is a substitution command of “standing” by “checkout” for the second command that i wrote, in reverse order on my bash historical past; it should take as arguments, those who i gave to my second command in the identical order.
That stated, the output of this command can be:git checkout second_folder
Fairly NEAT proper !?
So let’s discuss it, the !
invokes historical past enlargement, a characteristic that initially appeared within the C shell, again within the days earlier than you would rely on terminals to have arrow keys. It is particularly helpful in the event you add the present command quantity to the immediate (PS1="!$ "
) so you may shortly have a look at your display to get numbers for previous instructions.
So, am not going to go deep inside prospects right here however simply give some cool cheat-sheets from exclamations marks while you’re in your terminal !
This can be a fairly quick checklist of the cool ones :
-
!!
run the most recent command,
Ex :$ apt-get replace $ sudo !!
-
!-3
run the third command within the reverse order from my bash historical past; that is additionally out there for optimistic values resembling the primary command, out of your ~/.bash_history file resembling!1
-
!*
get arguments handed to the newest command runed,
Ex :$ contact filex, test4, instance $ chmod 777 !*
-
!ls
to run a command out of your historical past beginning withls
With these 4 gadgets, you may mainly play/combine round along with your bash historical past and get nice stuffs just like the one up there with a substitution string.