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
Written by Osvaldo Zonetti
Related protips
2 Responses
Nice to know when writing shell script! :-) thx. By the way when using interactive bash, I use the shortcut "M-." .
over 1 year ago
·
@yifu, this works only with emacs mode, with vi mode this shortcut doesn't work...
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#