[ILUG] Shell expansion questions

From: Rory Winston (Rory.Winston at domain telewest.co.uk)
Date: Mon 22 Oct 2001 - 10:43:35 IST


Hi,

I was just wondering if the following is possible in the shell.. I find the
$_ variable very handy (gives you the last argument of the previous
command), so you can type stuff like:

$ vim foobar.c
$ cat $_
$ gcc $_

Is there any way to get any other part of the previous command string? I.e.
if I type

$/usr/bin/foobar foo.c

Can I repeat the command, say like:

$$__ bar.c

And $__ (or similar) is expanded into the previous command
(/usr/bin/foobar)? Or are there any substitution mechanisms whereby I can
type something like

$ s/foo.c/bar.c

and the previous command is re-executed with the substitution in place. If
anybody knows of any trickery to do this stuff (or similar tricks) it would
be very handy. If we have any users who prefer Korn to Bash, any ideas on
the same mechanisms in ksh?

Cheers

Rory

--------------------------------------------
Rory Winston,
Developer,
OneLine Team,
TeleWest Communications,
Genesis Business Park,
Albert Drive,
Woking Surrey,
GU21 5RW

mailto: rory.winston at domain telewest.co.uk
phone: 01483 295 653

------------------------------------------------------------------------------
Live Life in Broadband
www.telewest.co.uk

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material.
Statements and opinions expressed in this e-mail may not represent those of the company. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender immediately and delete the material from any computer.

==============================================================================



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:12:51 GMT