It is currently Sat, 09 Dec 2023 05:58:29 GMT



 
Author Message
 Recursive grep alias in csh
How do I create an alias in csh (tcsh) that executes the following:

find . -exec grep ARG {} \;

where ARG is what I enter to the alias ?

How can I get the filename where the grep command finds something ?

/Roger



 Sun, 14 May 2006 18:10:35 GMT   
 Recursive grep alias in csh

With a shell script :

#!/bin/sh
grep $1 find . -print

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tel             +41 21 693 26 33
mobile          +41 79 513 74 10
fax             +41 21 693 76 00
www             http://ltswww.epfl.ch/~auric

GILLES AURIC EPFL Facult STI-ITS CH-1015 LAUSANNE SUISSE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



 Sun, 14 May 2006 21:48:08 GMT   
 Recursive grep alias in csh
Ok, but do you know how to make an csh-alias take an argument ?

news:3fc4af18$1@epflnews.epfl.ch...



 Sun, 14 May 2006 22:06:45 GMT   
 Recursive grep alias in csh

csh MAY be special, but aliases in any shell I use don't take arguments
- you need to define a function instead.

        Ed.



 Sun, 14 May 2006 23:04:16 GMT   
 Recursive grep alias in csh

If I recall correctly, csh aliases take arguments as history references,
e.g. !!:1

--
Kevin Rodgers



 Mon, 15 May 2006 01:54:08 GMT   
 Recursive grep alias in csh
"Roger Nilsson" <roger.a.nils...@ericsson.com> wrote

alias rgrep '/bin/find . -type f -exec /bin/grep \!$ {} \;'

and you invoke rgrep as:

rgrep ARG

change the paths to 'find' and 'grep' executables to their
proper locations. They are better hardcoded, for it might just
happen that 'find' &/or 'grep' themselves are aliased and
then 'rgrep' might not function as expected.



 Mon, 15 May 2006 03:11:33 GMT   
 Recursive grep alias in csh

If you want your alias to take just one argument, then use

alias rgrep '/bin/find . -type f -exec /bin/grep \!:1 {} \;'

--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.



 Mon, 15 May 2006 10:37:59 GMT   
 Recursive grep alias in csh
Big thanks to all that replied to my beg of help!!!

This was exactly what I was looking for!

/Roger

news:bq3o27$1dl$1@208.20.133.66...



 Mon, 15 May 2006 13:49:20 GMT   
 
   [ 8 post ] 

Similar Threads

1. csh, alias definition, recursive substitution, \ escape ???

2. Non-recursive Recursive Grep?

3. csh: if-then-else-endif in csh alias?

4. csh: if-then-else-endif in csh alias?

5. Do solaris users never do a recursive grep?

6. Recursive grep?

7. recursive grep?

8. recursive grep

9. Recursive grep


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software