title: Paste the last output and edit it in bash
body: <p>I like to use bash (on linux) without touching mouse.</p>
  
  <p>I often encounter the following situation.</p>
  
  <pre><code>$ locate libfreetype.a
  /usr/lib/x86_64-linux-gnu/libfreetype.a
  $ cd /usr/lib/x86_64-linux-gnu 
  </code></pre>
  
  <p>In this case, I copy <code>/usr/lib/x86_64-linux-gnu/</code> and paste it using mouse or type it. I do not want to do that.</p>
  
  <p>Ideally, the output of <code>locate libfreetype.a</code> is stored in somewhere (maybe in killring??) and paste it with <code>C-y</code> command and edit it on terminal.</p>
  
  <p>Are there good way to do this?
  (Just for this example case, there are smart one-line commands. But those are not the desired answers. I want a general solution.)</p>
  
  <hr>
  
  <p>Another example</p>
  
  <p>Suppose that I remember that there is a <code>memo...</code> in the same directory as <code>libfreetype.a</code> but I forgot the directory name.</p>
  
  <pre><code>$ locate libfreetype.a
  /usr/lib/x86_64-linux-gnu/libfreetype.a  
  $ nano /usr/lib/x86_64-linux-gnu/memo  # Tab completion here
  $ nano /usr/lib/x86_64-linux-gnu/memo_xxx.txt 
  </code></pre>
  
  <p>if I could cache the output <code>/usr/lib/x86_64-linux-gnu/libfreetype.a</code> and paste it, things are very easy.
  (<code>nano $(dirname $(locate libfreetype.a))/memo_xxx.txt</code> works for this case, but if I want to change the path itself, I need to think another technique.)</p>