Skip to content

Bash: get last arguments

Michael Watts edited this page May 22, 2019 · 1 revision

On commands that have single arguments this can be useful:

mkdir new-directory ; $_

Which will create you a new directory and change into it.

If the previous command had two arguments, like this

ls a.txt b.txt

and you wanted the first one, you could type

!:1

giving

a.txt

Or if you wanted both, you could type

!:1-2

giving

a.txt b.txt

You can extend this to any number of arguments, eg:

!:10-12

SSH

2 Best practices when logging in remotely to linux machine

WARGAMES

Clone this wiki locally