rjtnfq
Last Updated: January 28, 2019
·
760
· zonetti

Reusing the most recent parameter on CLI

After you use a command, for example:

ls /some/path

You can access the last parameter through the variable $_.

See for yourself:

echo $_

There is also another way in which you can be specific:

echo first second third fourth
echo !!:1 # first
echo !!:2 # second

2 Responses
Add your response

4716

Nice to know when writing shell script! :-) thx. By the way when using interactive bash, I use the shortcut "M-." .

over 1 year ago ·
18069

@yifu, this works only with emacs mode, with vi mode this shortcut doesn't work...

over 1 year ago ·