special-parameter
Bash $_ — previous last argument
In ordinary shell execution, expands to the last argument of the previous simple command after expansion. At startup and in the environment of executed commands it has other meanings; do not use it as a durable argument store. Capture immediately if needed. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): [last item].
Formal Syntax & Structure
bash syntaxbash
$_ / ${_}Return Value
string
Context-dependent special parameter.
Working Example
Example Snippetbash
printf '%s\n' first 'last item' >/dev/nullprintf '[%s]\n' "$_"