あまりフィルタリングされていない結果を保存できますか?

あまりフィルタリングされていない結果を保存できますか?

関連項目: (grep inside less)grepは少ないですか?

関連項目:(ファイルに少なく保存)https://superuser.com/questions/290908/how-can-i-save-the-current-contents-of-less-to-a-file

結果入力をフィルタリング&<regex>し、フィルタリングされていない結果を含むファイルを保存するとき。フィルタリングされた結果のみを保存できますか?

ベストアンサー1

ナビゲーション後、man less次のオプションが見つかりました。

-ofilename or --log-file=filename
              Causes less to copy its input to the named file as it is being viewed.  This applies only when the input file is a pipe, not an ordinary file.  If the file already exists, less will  ask  for
              confirmation before overwriting it.

       -Ofilename or --LOG-FILE=filename
              The -O option is like -o, but it will overwrite an existing file without asking for confirmation.

              If  no  log file has been specified, the -o and -O options can be used from within less to specify a log file.  Without a file name, they will simply report the name of the log file.  The "s"
              command is equivalent to specifying -o from within less.

したがって、このような操作を実行すると、出力ファイルを表示したときに得られるcat big_file.txt | less --log-file=output.txt出力になります。less

おすすめ記事