After browsing through man less
, I spotted the following options:
-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.
So if you do something like cat big_file.txt | less --log-file=output.txt
, you will get the output of less
in the output file as you view it.
dpoliaru@host:~$ less --version less 487 (GNU regular expressions)
– dmytro.poliarush Mar 03 '20 at 07:37