pfexec tip

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 07:40 AM GMT #

you can simply run "pfexec bash" ;-)

Posted by ddosia on April 29, 2009 at 08:43 PM 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 29, 2009 at 11:06 PM 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 02:47 AM GMT #

What would be the ksh93 equivalent?

Posted by Dave on August 25, 2009 at 07:11 PM 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 10:29 AM GMT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

The Observatory is a blog for users of Oracle Solaris. Tune in here for tips, tricks and more as we explore the Solaris operating system from Oracle.

Connect with Oracle Solaris:


Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
20
21
22
23
24
25
26
27
28
29
30
   
       
Today