user-avatar
Today is Saturday
May 4, 2024

November 12, 2009

how to get the last argument from the last command in the shell

by viggy — Categories: tech — Tags: , , , , Leave a comment

‘!$’ is the right answer.

For example: $vim test.pl
$chmod +x !$
$./!$

So what is happening above is
first vim test.pl opens a file.
then after you have written a perl script, you would like to make it executable. There is no need for you to specify the file name again. You can just use !$.
In the third command again to execute the file, there is no need to mention the file name again. You just use !$ again.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>