I'm trying make a function that simplifies grepping a log I have to work with on a regular basis.
I'd like to use extended regexp with it pipe and redirect the output, etc.
But I'm having trouble doing this using the standard grep pattern file syntax in the function.
The way I have it set up now is horrible to look at, but gets the job done:
alias mygrep='cat /path/to/logs/my.log | grep'
This allows me to run the following without trouble
mygrep -i -E "WARN|java" |less
Seems like the correct implementation should be something like the following.
function mygrep () {
args=$*
grep "$args" /path/to/logs/my.log
}
However when I use this with the search and pipe parameters above, grep returns an invalid option error.
What am I missing?
$args
and just sayinggrep "$@" /path/to/logs/my.log
.