Less - Select to clipboard
Solution 1:
Generally, no.
Specifically, any such capabilities will depend on multiple factors.
less itself runs inside a terminal environment, and doesn't really know of the clipboard at all.
Your terminal emulator provides clipboard interaction, but probably doesn't have much intelligence in terms of what's currently displayed inside the emulated terminal.
It probably isn't impossible to write a text-mode application that can make use of the X APIs to eventually interact with the clipboard, but it'd likely be a lot of work for very little gain, given that it's often quite easy to enlarge the terminal emulator window, or copy and paste multiple times.
In the specific case of less, consider removing less
from the equation entirely. If the file is not too large or otherwise inappropriate to just dump onto the terminal, just cat
it to the terminal instead, and use the terminal emulator's scrollback buffer to select the text you want to. With an appropriately sized scrollback buffer, that will allow you to copy all the text you want to copy in one operation.
Since we've found that you really are trying to just get a section of a text file, you can use a command like sed -n M,Np infile > outfile
to extract the range of lines M
through N
from the file named infile
. For example, to extract lines 10,000 through 20,000, you'd use sed -n 10000,20000p infile > outfile
. How can I extract a range of lines from a text file on unix? has additional suggested solutions for how to solve that problem.