[comp.unix.shell] Korn shell emulation of Csh's !? ???

cpcahil@virtech.uucp (Conor P. Cahill) (01/27/91)

In article <16554@ogicse.ogi.edu> morgan@ogicse.cse.ogi.edu (Clark O. Morgan) writes:
>I'd just like to be able, from the Korn shell command line, to type:
>
>  r <meta_sequence><word><CR>

In VI mode the sequence would be:

	<ESC>/<word><CR><CR>

The first CR ends the search specification and pulls up the last command
that has that word in it and the second <CR> executes that command.  If you 
decide that you don't like that command you can use 'n' insteac of <CR> to
get the previous entry (and so on.....)

-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 

dws@margay.cs.wisc.edu (DaviD W. Sanderson) (01/29/91)

In article <16554@ogicse.ogi.edu> morgan@ogicse.cse.ogi.edu (Clark O. Morgan) writes:
>I've recently switched over to Korn shell from Csh and am quite happy.
>However, I dearly miss the Csh !? history recall feature (which permits
>commands to be recalled by "words" anywhere in a command string, not
>just at the beginning of the command).

You can put arbitrary words from your previous command into the current
command with the underscore command in vi mode.  The man page says:

	[count]_	Causes the count word of the previous command
			to be appended and input mode entered.  The
			last word is used if count is omitted.

So to recall the second word of the previous command, you can say

	<ESC>2_

and continue typing.
-- 
       ___
      / __\  U N S H I N E	           DaviD W. Sanderson
     |  |  | I N E			    dws@cs.wisc.edu
_____|  |  |_____  ________
\      / \   |__/ /////__	Fusion Powered Locomotives Made to Order
 \____/   \__|_/  \\\\\______	 (TARDIS model available at extra cost)