From: Jeffrey Holle <jeff.holle@verizon.net>
To: linux-console@vger.kernel.org
Subject: Re: encapulating a find function in a script
Date: Fri, 16 Jan 2004 13:09:43 -0800 [thread overview]
Message-ID: <bu9k3v$nul$1@sea.gmane.org> (raw)
In-Reply-To: <bu4s3j$atl$1@sea.gmane.org>
Got both original script and the suggested speed enhanced script to work
by putting a double double quote around the second parameter reference,
like ""$2"".
This was necessary to allow this parameter to be something like "*.cpp".
Without this treatment, *.cpp was expanded to the cpp files that
happened to be in my current directory.
I'm using Mandrake 9.1 linux and employing the bash command shell.
Do other linux/unix oses have this strange behavior?
Jeffrey Holle wrote:
> 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.
>
> BobGian@U.Washington.edu 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 majordomo@vger.kernel.org
>> 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 majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2004-01-16 21:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-15 0:34 encapulating a find function in a script BobGian
2004-01-15 1:00 ` Mike Castle
2004-01-15 1:55 ` Jeffrey Holle
2004-01-16 21:09 ` Jeffrey Holle [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-01-16 19:53 BobGian
2004-01-16 20:09 ` Mike Castle
2004-01-15 0:19 Jeffrey Holle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='bu9k3v$nul$1@sea.gmane.org' \
--to=jeff.holle@verizon.net \
--cc=linux-console@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).