Bash: Use previous expression parameters

I was running a bash command similar to this:

perl /var/www/scott/perl/test/scott.pl --size 10 --file /tmp/output.txt

and afterwards I wanted to make a small change to that script. Rather than typing out the full path you can use some Bash history expansion and do this instead:

vim !:1

If you use !: followed by a number, Bash will replace that with the Xth (starting at zero) parameter from the previous command.

Leave A Reply
All content licensed under the Creative Commons License