This is the mail archive of the
mailing list for the Cygwin project.
Re: Easy, quick, BASH question
- From: Randall R Schulz <rrschulz at cris dot com>
- To: "Barnhart, Kevin" <Kevin dot Barnhart at echostar dot com>, "'cygwin at cygwin dot com'" <cygwin at cygwin dot com>
- Date: Fri, 02 Aug 2002 16:31:13 -0700
- Subject: Re: Easy, quick, BASH question
In BASH aliases are much more limited than they are in CSH/TCSH. BASH
aliases can only perform a left-hand substitution for the aliased command.
It can be a multi-word substitution, but the alias is a completely
unparameterized substitution and the substitution remains strictly at the
left of the resulting command with any arguments passed to the alias added
on the right / after those appearing in the alias definition.
To get anything more complicated, you must use a shell procedure. E.g.:
grep -n "$@" $(find -name '*.[ch]')
Note that you want to use "$@" not "$*" since the former yields each
argument individually quoted whereas the second produces a single argument
to grep consisting of each argument to chgrep concatenated with a single
space interpolated between each.
Mountain View, CA USA
At 15:04 2002-08-02, Barnhart, Kevin wrote:
I'm trying to setup an alias for grep that recursively looks through all .c
and .h files for a string. So far I've tried variations of:
alias hcgrep='grep -n "$*" $(find . -name '*.[ch]')'
There's probably just one little thing I'm missing...
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html