$ pidof qqq
$ cd /proc/
           ^ cursor here

And now I want to auto-insert the previous line here. Of course I can manually type 12345 or `pidof qqq`, but how to do it conveniently?

The question is not solely about pidof and /proc, but about any such situation of reusing previous command output.


1 Answer 1


You can use the following:

cd /proc/$(!!)
  • 4
    That is just rerunning the previous command which could output something different the second time it is ran.
    – llua
    Commented Sep 12, 2013 at 11:23
  • Or `!!` - even easier to type (if there is no backticks in previous command).
    – Vi.
    Commented Sep 12, 2013 at 11:23
  • @llua Good point, the command might also have some other undesirable side-effects (e.g. script which starts a daemon and outputs the pid of the newly created process). Commented Sep 12, 2013 at 11:38
  • Maybe the correct implementation should be on side of pseudo-terminal master? I.e. it should be gnome-terminal's (or whatever) shortcut like "Insert penultimate line here". Related: stackoverflow.com/a/10059590/266720
    – Vi.
    Commented Sep 12, 2013 at 12:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .