quora appears broken at the moment . . . I was going to suggest:<p>in many shells (bash, tcsh, etc), !foo will execute the most recent command from your history that matches foo, for example:<p><pre><code> > grep -lots -of -options /complicated_regex/ ./some/path/* | /pipe/filter
# realize you are in the wrong directory
> cd /the/right/directory
> !g
</code></pre>
and similarly, !! is the most recent command, which comes in handy for "sudo !!"[1]<p>[1] <a href="http://xkcd.com/149/" rel="nofollow">http://xkcd.com/149/</a>