Bash – How to insert the output of previous command into current command line

bash

$ pidof qqq
12345
$ 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.

Best Answer

You can use the following:

cd /proc/$(!!)