less: 複数のフィルタ条件に AND を使用

less: 複数のフィルタ条件に AND を使用

ANDでリンクされた複数のフィルタ条件をLessとして指定する方法は?

行に「nat」は含まれていませんが、IPアドレス192.168.1.1を含むログをフィルタリングしたいと思います。たとえば、次のようになります。

&/!nat && 192.168.1.1

しかし、うまくいかず、結果が空です...

アドバイスしてください。

ベストアンサー1

バージョンv569から少ないログファイルを「ドリルダウン」するためにフィルタを「スタック」することができます。

マニュアルページから:

&pattern
              Display  only  lines which match the pattern; lines which do not
              match the pattern are not displayed.  If pattern  is  empty  (if
              you  type  &  immediately  followed  by ENTER), any filtering is
              turned off, and all lines are displayed.  While filtering is  in
              effect,  an  ampersand  is  displayed  at  the  beginning of the
              prompt, as a reminder that some lines in the file may be hidden.
              Multiple  &  commands  may  be entered, in which case only lines
              which match all of the patterns will be displayed.

              Certain characters are special as in the / command:

              ^N or !
                     Display only lines which do NOT match the pattern.

              ^R     Don't interpret regular expression  metacharacters;  that
                     is, do a simple textual comparison.

&!natEnterしたがって、ここで次のことを行う&Ctrl+R192.168.1.1Enterか、exampleの内部一致を避けます192.168.1.1192.168.1.123&Ctrl+R\<192\.168\.1\.1\>Enter

おすすめ記事