1

multitail has a nice regex-based filtering mechanism that is described in the manpage and online manual. Both sources state that log lines matching a given regex can be excluded from output using the -ev switch:

multitail -ev "ignorelinescontainingthis" /var/log/whatever.log -ev "alsoignorethis" /var/log/another.log

This does, however, not seem to work for filtering many log files that are passed using wildcards:

multitail -ev "thisdoesntwork" /var/log/myservice*.log

Is there a way to get this to work?

For analysis purposes, I tried the -ec switch (which highlights regex matches) and it turns out that the filter is only applied to the first file in the wildcard list, but none of the other ones.

jstarek
  • 1,672
  • 2
  • 16
  • 32
  • 1
    I'm making a guess based on the man page. Using `-Ev` instead of `-ev` might work. The `-v` option would negate the regex, and the `-E` option would apply that to all following files. – Haxiel Nov 28 '19 at 17:14
  • That's it, thanks a lot! No idea how I could possibly have missed that... anyway, feel free to create a real answer so that I can accept it. – jstarek Nov 28 '19 at 21:14
  • Glad to know that it worked. I've added the solution as a proper answer. Just in case it helps, my approach was to first locate the `-e` option on the man page and see how it was defined. From there, I searched for the phrase 'regular expression' to find all the available options that had something to do with regexes. There were only about five options, so I quickly hit upon the right one (`-E`). – Haxiel Nov 29 '19 at 15:42

1 Answers1

2

Turning my comment into an answer.

The man page for multitail defines the -e option as follows:

-e Use the next regular expression on the following file.

So the regular expression filter only applies to the immediately following file. When using shell globs, this would result in the filter being applied only to the first file in the expanded list of files.

To apply the regular expression filter across all files, the -E option must be used instead:

-E Use the next regular expression on the following files.

The -v option, which negates the specified regular expression, should work in the same manner for either of these options.

Haxiel
  • 8,201
  • 1
  • 20
  • 30