From: puzzlecracker on
I see this alias is being used

like env | grep \!* some Somestring (to find string env. variables
that start with some string). I am not sure what '!* ' in the
expression mean.


thx
From: Barry Margolin on
In article
<48951a47-f30f-4868-84db-d6b39c42c2e1(a)s50g2000hsb.googlegroups.com>,
puzzlecracker <ironsel2000(a)gmail.com> wrote:

> I see this alias is being used
>
> like env | grep \!* some Somestring (to find string env. variables
> that start with some string). I am not sure what '!* ' in the
> expression mean.

\!* in a C-shell alias gets replaced with the parameters to the alias.
It's like $* in a script.

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Andre Majorel on
On 2008-06-16, puzzlecracker <ironsel2000(a)gmail.com> wrote:

> I see this alias is being used
>
> like env | grep \!* some Somestring (to find string env. variables

What ? Is the command really "env | grep \!* some Sometring" ?

> that start with some string). I am not sure what '!* ' in the
> expression mean.

What shell is this ?

--
Andr� Majorel <URL:http://www.teaser.fr/~amajorel/>
"Cette supposition rappelle assez celle de ce pr�dicateur qui, en
pleine chaire, faisait remarquer � ses fid�les la bont� de Dieu qui
avait plac� les rivi�res aupr�s des villes." -- Alexandre Dumas
From: puzzlecracker on

> \!* in a C-shell alias gets replaced with the parameters to the alias.
> It's like $* in a script.

Sorry, I am not sure what you mean , would you please elaborate on
this?

What do you mean parameters to the alias?




From: Maxwell Lol on
puzzlecracker <ironsel2000(a)gmail.com> writes:

>> \!* in a C-shell alias gets replaced with the parameters to the alias.
>> It's like $* in a script.
>
> Sorry, I am not sure what you mean , would you please elaborate on
> this?
>
> What do you mean parameters to the alias?


If you define an alias in (t)csh as in

alias rm rm -i
when you type "rm" the csh changes it to "rm -i"
By default, it changes what you type for the alias.
Arguments to the alias are appended, so that
rm a*
becomes
rm -i a*

But suppose you want to pass it an argument to an alias in the middle
of the alias.

Let's say you want to type an alias
lsh abc*
and make it be the same as
ls abc* | head

The alias
alias lsh 'ls | head'
would expand to become
ls | head abc*
which is wrong.

So, instead, you need to use the \!*:

alias lsh "ls \!* |head"

will do this. If you used a posix shell, you would use a function and
use $* instead of \!*


The csh forces you to place a "\" before the "!" because "!" is a
special character.

There are options besides !* - which expands to all arguments
\!1 - first argument
\!2 - second argument
etc. See the manual page for more info.

You can use the ":" modifiers to modify the parameter. :r discards the
extension and keeps the root, so the alias
alias ccc 'cc -o \!1:r \!*'
will change
ccc prog.c sub1.c sub2.c
into
cc -o prog prog.c sub1.c sub2.c
Note how "prog" is repeated.