less の grep モード的な何か
less の tail -f モード的な何か - YoshioriのBlog
id:sett-4 : (less で) shift+Fでtail -fモードに。Ctrl+Cで脱出
他にも機能あるかなーと思ってmanを覗いていたら、grep モード相当の機能を発見。
&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. 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.
lessで「&」を入力して検索語句を指定すると、検索語句が含まれる行のみ表示される。いちいちlessを抜けてgrepする必要なし。おおお。
ただし、この機能が追加されたのはlessのtarball同梱のNEWSによるとバージョン418から424の間の模様。
====================================================================== Major changes between "less" versions 418 and 424 * New "&" command allows filtering of lines based on a pattern.
lvは残念ながら現時点では対応していない。
各システムの対応状況
システム | 対応状況 |
---|---|
CentOS | CentOS5以降対応 |
Debian | testing(squeeze)以降対応 |
Fedora | 10以降対応 |
Gentoo | 2009年2月以降対応 |
Ubuntu | Ubuntu 9.10(karmic)以降対応 |
Vine | 5.2以降対応 |
Cygwin | 対応(対応時期不明) |
Mac OS X | 10.6.5時点で未対応 |
FreeBSD | 8.2以降対応 |
NetBSD | 未対応 |
OpenBSD | 不明 |
tail -fモードと組み合わせられる?
Fのtail -fモードと組み合わせれば、
tail -f hoge | grep fuga
と同じことがlessでできる!?と思ったけど残念ながら未対応。今後に期待。
まぁtmux上でtail -f hoge | grep fugaすればいいんじゃないでしょうか。私はawk派ですが。
おまけ
ほう!そんなものが! RT @tdw777: @matsuu tmux もいいけど multitail もいいっす.特にトラブルシューティング時. http://www.vanheusden.com/multitail/
MultiTailは要チェキ