How can I run a different command but with the same arguments?
Use !*
. It expands to all words except the first one (i.e. the command).
$ vim arbit.py
$ python !*
python arbit.py
You can combine it with all the features of !
, for example:
$ vim arbit.py
$ ls
$ python !vim:*
vim arbit.py
Or, if you want only the last word, there are two other ways:
$ vim arbit.py
$ python !$
or:
$ vim arbit.py
$ python <Esc+.>
See the bash history interaction documentation for more details.
There are at least a couple of ways to do this.
$ vim arbit.py
$ python[press Alt-.]
which retrieves the last argument of the previous command as does:
$ vim arbit.py
$ python !$
or
$ vim arbit.py
$ python !*
which retrieves all the arguments of the previous command.