Issue
I have a command with parameters in shell. like
Command -a -b
assume a
b
are very long directory name, and they are not always the first and last parameters.
However, I need to use this command again. I use ctrl+p
to go back the command, but this time I need to reverse a
b
order.
Command -b -a
Instead of retyping them again, is there any way to fast swap them?
Thanks in advance.
Solution
Yes you can use history substitution:
$ echo foo bar
foo bar
$ !:0 !:2 !:1 # previous command with second arg then first arg
echo bar foo
bar foo
$
Answered By - Paul R Answer Checked By - David Goodson (WPSolving Volunteer)