[clug] Favourite shell one liner

Francis James Whittle fj.whittle at gmail.com
Sat Dec 31 18:41:14 MST 2011


I recently had cause to use this where I'd put an underscore instead of
a space.  The "command" looked like this:

^_^ 

On a shared shell environment, I'm sure someone scrolling through the
history would have been confused by it....

On Wed, 2011-12-21 at 15:14 +1100, Brendan Jurd wrote:
> On 20 December 2011 21:46, Hal Ashburner <hal at ashburner.info> wrote:
> > Hi Clug!
> >
> > What's your favourite* shell** one liner?
> 
> Not technically a one-liner, but just a nice little trick in bash that
> I have recently started using.
> 
> Ever entered a shell command and then realised you actually wanted to
> do something just a little bit different from what you typed?
> 
> ^foo^bar
> 
> Substitutes the first 'foo' with 'bar' in the most recently entered
> command in your history, and then executes the result.
> 
> Real world example:
> 
> $ ls /path/to/file
> 
> Okay, I've checked that it exists, now I want to edit it:
> 
> $ ^ls^vim
> 
> Also good for correcting typos without having to fool around with
> arrow keys, or M-b and M-f.
> 
> Cheers,
> BJ




More information about the linux mailing list