Lurker News
Back to discussion

Comment by Syssiphus

Syssiphus2 replies#
Pressing ESC and then _ will insert the last argument of the last line. Repeat to go up in the history.

If you go through the command history and press CTRL-o on a line it will be executed and the command on the commandline will be replaced by the next line in the history.

oinksoft1 reply#
In Bash, you also can use the $_ variable which is the last argument of the previous command:

  $ stat /tmp/foobar
    File: `/tmp/foobar'
    Size: 0         	Blocks: 0          IO Block: 4096
    ...

  $ rm -v $_
  removed `/tmp/foobar'
hk__21 reply#
You can also use `!$`.
yawboakye#
!$ runs the last command. it's bad if the last command is of the form command arg... because it'd run command without every other argument passed in the command line
philsnow#
Also M-. (meta-period). Keep banging on M-. to pull in the last argument of preceding commands.

With a numeric prefix argument N, it grabs the Nth-from-the-end argument of the previous command, so M-3 M-. grabs the 3rd-from-last argument from the previous command.