How can I use the bash history to run a command with the arguments from a command in the history?
I know that I can use !!
to rerun the last command, but how can I run a new command with those arguments?
eg, I first run:
~/somefolder/script.sh somefile
I want to quickly run
~/somefolder/script.sh anotherfile
I tried !! anotherfile
but it didn't work.
Or even better, how can I run !-2 newarguments
to run the second last history command with new arguments?
I don't want to use the arrows to scroll through the history then backspace over the arguments.