help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Grep pattern from files


From: michael-franzese
Subject: Re: Grep pattern from files
Date: Thu, 22 Apr 2021 22:36:35 +0200

I figured out that the problem wan in hor I was trying to call it

grepot "--include=*.el -C 8 ddd ./"

rather than

grepot --include="*.el" -C 8 ddd ./

Would you have some hints on useful ways to call the function
for regular expressions?

> Sent: Friday, April 23, 2021 at 8:26 AM
> From: "Greg Wooledge" <greg@wooledge.org>
> To: help-bash@gnu.org
> Subject: Re: Grep pattern from files
>
> On Thu, Apr 22, 2021 at 09:56:22PM +0200, michael-franzese@gmx.com wrote:
> > grepot ()
> >   {
> >     grep --include="*.org" --include="*.texi" -hir "${1}" "$@:2"
> >   }
> >
> > But testing it with
> >
> > grepot --include="*.el" "-C 8 ddd ./"
>
> In your previous message, you said you designed your function to require
> three arguments: a number, a pattern, and a directory.  However, this is
> not what you passed to it.  You passed two arguments, the first being
> something that looks like an option, and the second being a concatenation
> of another option-looking thing, a number, a pattern, and a directory.
>
> You appear to be over-complicating everything, and quoting incorrectly.
> Why not just write it like a wrapper:
>
> grepot() {
>   grep --include="*.org" --include="*.texi" -hir "$@"
> }
>
> Then you can pass whatever options and arguments you like to it:
>
> grepot --include="*.el" -C 8 ddd ./
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]