是否可以保存较少的过滤结果

是否可以保存较少的过滤结果

相关于:(less 内部的 grep)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

相关内容