[sf-lug] My favorite simple little Linux tips

Mike Higashi mhigashi at gmail.com
Fri Jul 30 17:12:18 PDT 2010

On Fri, Jul 30, 2010 at 4:33 PM,  <testcore at gmail.com> wrote:
> But, you didn't mention one of my favorites that I've found to be obscure (maybe not for this list, but eh).  If you want to perform the same command, only with one change, instead of scrolling up and then typing the change, I use this:
> ^oldVal^newVal
> I find it most useful when I check a file via 'ls', and then want to inspect the contents via 'less':
> ls myfile
> ^ls^less >Evals to 'less myfile'

I was thinking about including some command shortcuts.  I've
heard about the one you mentioned, but it just never got into
my toolkit of tricks that I use on a regular basis.

The one I'm in the habit of using instead is the !$ shortcut:

  ls myfile
  less !$   ==>  evals to 'less myfile'


The downside is the two commands have to be consecutive,
which I think is also the case the ^string1^string2 case.

The advantage of '^string1^string2' is that string1 does not have to be
at the start of the command, so you can make spelling corrections
to errors in the middle of a long command this way, but I'm used to
just hitting the up arrow and editing the command line instead.

And while I'm at it, I should point out that when editing a long command
from your command history, Control-A is the default keybinding for
moving the cursor to the start of the line, and Control-E moves you to
the end.

The other shortcut I like is when you prepend an '!' to a command
to re-run the same command once again:

  vim some-really-long-filename
  [many more commands, which do not use vim]
  !vim     ==> evails to 'vim some-really-long-filename'


More information about the sf-lug mailing list