Re: encapulating a find function in a script
Jeffrey Holle <[email protected]> Wed, 14 Jan 2004 17:55:41 -0800
| Newsgroups | gmane.linux.console |
|---|---|
| Message-ID | <[email protected]> |
No joy. The problem appears to be the '*' character. If I substitute an actual cpp filename, the script works. However it not very useful this way. [email protected] wrote: >>I'm having a problem with a simple script I'm trying to develop. >> >>Its name is fgrep and its text is: >> >> #!/bin/bash >> find $1 -name $2 -exec grep -H $3 '{}' ';' >> >>I want to use it like "dgrep 'directory' 'file pattern' 'match text'. >> >>It doesn't match anything because of the $2 parameter. If I replace >>"$2" with "*.cpp", it works. >> >>Can anybody tell me what is wrong and how to fix it? > > > Try putting double-quotes around the parameters, like: > > find $1 -name "$2" -exec grep -H "$3" '{}' ';' > > This works for me in a similar script, at least in the csh shell. > > -Bob Giansiracusa > - > To unsubscribe from this list: send the line "unsubscribe linux-console" in > the body of a message to [email protected] > More majordomo info at http://vger.kernel.org/majordomo-info.html > - To unsubscribe from this list: send the line "unsubscribe linux-console" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html