ページ化された出力用の対話型フィルタリングツールはありますか?

ページ化された出力用の対話型フィルタリングツールはありますか?

プログラムの出力を取得し、次のコマンドでパイプされる行を対話式にフィルタリングしたいと思います。

ls | interactive-filter | xargs rm

たとえば、パターンを減らして一致させることができないファイルのリストがあります。interactive-filterファイルリストの出力をページングするコマンドを使用し、次のコマンドに渡す行を対話形式で表示できます。この場合、すべての行が削除されます。

ベストアンサー1

  1. iselectユーザーが複数の項目(次のパイプの出力)を表示できるコンテキストのリスト(前のパイプの入力)を提供します。

    # show some available executables ending in '*sh*' to run through `whatis`
    find /bin /sbin /usr/bin -maxdepth 1 -type f -executable -name '*sh'   |
    iselect -t "select some executables to run 'whatis' on..." -a -m |
    xargs -d '\n' -r whatis 
    

    私のシステムにいくつかのマーキングを表示するためにスペースバーを押した後の出力:

    dash (1)             - command interpreter (shell)
    ssh (1)              - OpenSSH SSH client (remote login program)
    mosh (1)             - mobile shell with roaming and intelligent local echo
    yash (1)             - a POSIX-compliant command line shell
    
  2. vipeパイプを通過するコンテンツをインタラクティブに編集(希望のテキストエディタを使用)できます。例:

    # take a list of executables with long names from `/bin`, edit that
    # list as needed with `mcedit`, and run `wc` on the output.
    find /bin -type f | grep '...............' | EDITOR=mcedit vipe | xargs wc
    

    出力(からいくつかの行を削除した後mcedit):

       378   2505  67608 /bin/ntfs-3g.secaudit
       334   2250 105136 /bin/lowntfs-3g
       67    952  27152 /bin/nc.traditional
       126    877  47544 /bin/systemd-machine-id-setup
       905   6584 247440 total
    

プッシュとプルの注意:

  • iselect次のリストから始めてください。何もない選択。
  • vipe次のリストから始めてください。すべて表示された項目は、ユーザーが削除しない限り、パイプを介して送信されます。

存在するダーバンディストリビューションに応じて、両方のユーティリティapt-get install moreutils iselect

おすすめ記事