Sometimes it is necessary to pass a part of argument of one command as argument towards next command in the terminal. This can be pretty painful if the output of first command is long or hard to type or you are using VM without possibility to use the good old copy-paste.

For example, if I were to use the following command:

$ echo alice bob charlie
alice bob charlie

and want to pass the last argument towards another one then I can do so by using a simple !$:

$ echo !$
$ echo charlie

This basically substitutes the !$ with the last argument of the previous command. Now if we need the first argument then it can be done using !^ like:

$ echo !^
$ echo alice

The key ^ and $ are often to represent the first and last of something. For instance, in vim these keys allow moving the cursor to the beginning and the end of the line, respectively. Furthermore, in regex those keys are used to match the beginning or end of the line.