From less
, type s then type the file name you want to save to, then Enter.
From the man
page, under COMMANDS
:
s filename
Save the input to a file. This only works if the input is a pipe, not an ordinary file.
man
page also states that, depending on your particular installation, the s
command might not be available. In that case, you could go to line 1 with:
g or < or ESC-<
Go to line N in the file, default 1 (beginning of file).
and pipe the whole content to cat
with:
| <m> shell-command
<m> represents any mark letter. Pipes a section of the input file to the
given shell command. The section of the file to be piped is between the
first line on the current screen and the position marked by the letter.
<m> may also be ^ or $ to indicate beginning or end of file respectively.
so either:
g|$cat > filename
or:
<|$cat > filename
i.e. type g or < (g or less-than) | $ (pipe then dollar) then cat > filename
and Enter.
This should work whether input is a pipe or an ordinary file.
less
once I've already openedless
. – Flimm Dec 10 '14 at 21:02