3 ms·
$_ in bash means the last argument of the previous command. So: mkdir some/long/path/to/a/dir cd $_ mv foo some/long/path/bar cd $_ both work for what you wa
by vram22 13y ago
$_ in bash means the last argument of the previous command. So:
mkdir some/long/path/to/a/dir
cd $_
mv foo some/long/path/bar
cd $_
both work for what you want, and the extra keystrokes are so few that it hardly matters. The $_ is not specific to those two commands, so works for others as well, and is typically very useful because command sequences often tend to need the last argument of the previous command in the next command; un-tar-ing a .tar file and then going to the extracted directory is another example.