Re: how to make a script of this one-liner...



At 2008-04-25 11:30AM, "Arnaud Dagnelies" wrote:

Hello,
I would like to write a small script used as follows:

igrep ***

That basically simply performs the grep and formats the output in a
special way using another script. In short, what should be executed
is:

grep *** | someScript

...where the *** is anything that can be given to grep. Thus not only
the pattern and files but also including flags and params and so on.

What would be the easiest way to do that?

If you use a POSIX shell, use a function:

igrep() {
grep "$@" | somescript
}


--
Glenn Jackman
"If there is anything the nonconformist hates worse than a conformist,
it's another nonconformist who doesn't conform to the prevailing
standard of nonconformity." -- Bill Vaughan
.



Relevant Pages

  • Re: Find a line in a text file then print a field
    ... Here is "grep" part of my perl script so far (ommitting the various ... the matching lines in an array. ...
    (perl.beginners)
  • Re: [PATCH] kconfig: simplification of scripts/extract-ikconfig
    ... I found a way to work around the differences in behavior of grep. ... I've rewritten the extract-ikconfig script to extract the kernel ... -# GNU General Public License for more details. ...
    (Linux-Kernel)
  • Re: I need a custom script to extract data from my web logs.
    ... >> You aren't passing anything to awk and you don't need awk anyway. ... My original script was using awk to output the data by ... > piping the output of the original grep through awk to the printf. ... (i.e. searchlogs log???? ...
    (comp.unix.shell)
  • Re: Standard output piping problem
    ... >> Why won't the multiple pipes present output? ... Barry in his reply suggested that it's a buffering issue and to test ... this I let the script run for a few minutes. ... Truth be told I was going to use grep as it was simpler than working out how ...
    (comp.unix.shell)
  • Re: [PATCH] kconfig: simplification of scripts/extract-ikconfig
    ... The version of grep on the machines I tested on does ... modified the script to use perl instead. ... I've rewritten the extract-ikconfig script to extract the kernel ... -# GNU General Public License for more details. ...
    (Linux-Kernel)