Skip to content
The Bash Insectarium

/static/insetario/en/inseto/sublinhado/

Menu

BSH-019 · Ghost variables

$_

The previous command's last argument, kept in an underscore.

After every command, the shell notes the last argument in $_. A mkdir followed by cd $_ enters the freshly made directory without repeating the path.

It is the domestic cousin of the Reliquary's !$: same trade, but as an ordinary variable — it works in scripts and with history expansion turned off. On the session's first line, it holds the shell's own path.

$ mkdir -p ninho/ovos/2026
$ cd $_
$ pwd
/home/ana/ninho/ovos/2026
Made it and entered it, without typing the path twice.