[clug] Favourite shell one liner
Brendan Jurd
direvus at gmail.com
Tue Dec 20 21:14:46 MST 2011
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