How many times a day do you type a command in which you inadvertently forget to prepend with pfexec? For example:
bleonard@opensolaris:~$ zfs set compression=on rpool
cannot set property for 'rpool': permission denied
Rather than reentering or editing the previous command, you can quickly re-run it using:
pfexec !!
!! is the bash shortcut for running the previous command.
Comments:

Very nice!

Posted by Marc Poljak on April 29, 2009 at 02:40 PM GMT #

you can simply run "pfexec bash" ;-)

Posted by ddosia on April 30, 2009 at 03:43 AM GMT #

I know this feature, but I usually don't feel safe using it. I feel safer if I can see the actual line, either using TAB between !! and RETURN in zsh, or simply using the up arrow, CTRL+A and adding pfexec at the beginning of the line.

Posted by Marc on April 30, 2009 at 06:06 AM GMT #

You can select the arguments of the previous command using !!:1, !!:2 and so on and many other things (see http://www.gnu.org/software/bash/manual/bashref.html#History-Interaction )

Posted by Georg on May 06, 2009 at 09:47 AM GMT #

What would be the ksh93 equivalent?

Posted by Dave on August 26, 2009 at 02:11 AM GMT #

bangbang is actually a csh thing, not a Bourne shell thing. Apparently the nice bash people tacked it on at some point, which was certainly a good move. It'd be nice if they would endeavor to learn more yet from the csh folks.

Posted by jake on October 06, 2009 at 05:29 PM GMT #

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by Roman Strobl