help-bash
[Top][All Lists]
Advanced

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

Re: Grep pattern from files


From: Greg Wooledge
Subject: Re: Grep pattern from files
Date: Thu, 22 Apr 2021 16:26:45 -0400

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]