How to copy all text in edited file from PuTTY to clipboard?

9

3

In addition to this question: PuTTY how to select text and copy text using keyboard ONLY

I want to copy all text from file that I see in PuTTY to my Windows session. Something that in Windows would be done with Ctrl + A.

What is the equivalent in PuTTY?

Edit:

What I actually have is a long text file.
In Putty I can forward to the "next page" using Ctrl + V or simply going down with the arrow rows. The limit of row that I can see is with the height of my screen. If I could to see all of them I would simply mark them and copy them.. But I can't....

Think of it like a 400 pages long of word document you simply click Ctrl + A in the document and then you can copy it all. This is what I need in PuTTY.

avi

Posted 2017-03-07T07:23:23.863

Reputation: 213

copy all text from file that I see - That's pretty vague. How do you "see" it? What tool/command do you use to "see" it? – Martin Prikryl – 2017-03-07T07:59:06.567

@MartinPrikryl Please see my edit – avi – 2017-03-07T08:02:37.120

Check my answer - Though you still didn't explain what tool/command do you use to "see" the file. – Martin Prikryl – 2017-03-07T08:07:18.117

You have actually asked this already few months back: http://superuser.com/q/1156010/213663

– Martin Prikryl – 2017-03-07T08:30:39.307

Your edit does not change anything, we understand, what you want! It cannot be done! Again, as per my answer. PuTTY cannot access the other lines on your remote editor. And the remote editor cannot access the local clipboard. The period. There's no way around that! Use a local editor that supports SFTP or SFTP client with editing capability. See https://winscp.net/eng/docs/ui_editor

– Martin Prikryl – 2017-03-07T09:02:11.047

The cat is explicitly mentioned in my answer, as well as in my answer to your previous duplicate question. – Martin Prikryl – 2017-03-07T09:05:55.210

Answers

8

You can select all text in PuTTY by clicking the title bar icon and selecting "Copy all to clipboard":

putty select all

This will only copy the entire scrollback buffer. If your file is longer than the scrollback buffer, you will have to increase it. This can be done under "Window"->"Lines of scrollback".

putty scrollback

mtak

Posted 2017-03-07T07:23:23.863

Reputation: 11 805

Thanks this is better but this doesn't solve the issue. My file is very long... it copy the entier session but from the file it copy only the visible section... try do that with a long text file you'll see it doesn't copy it all. – avi – 2017-03-07T07:56:51.250

@avi Updated my answer. Probably your scrollback isn't big enough to hold the entire file. You should consider using SCP (WinSCP/pscp.exe) to transfer the file though. – mtak – 2017-03-07T08:23:15.700

Ok I found why you didn't understand me. I used nano file.py which didn't show the whole file.. now I use cat file.py and your solution works. cat loads the entire file to the console so you can scroll up and down the file and then I can mark it and copy it. it's important to highlight that cat command needs to be used to solve it :) – avi – 2017-03-07T09:02:42.463

So it's the same as http://superuser.com/questions/741526/copy-the-entire-content-of-a-file-opened-in-putty-to-clipboard/741532#741532 ? Maybe do a better search next time :)

– mtak – 2017-03-07T09:46:41.283

Putty for linux does not have an option to right click & copy all to clipboard – user1502776 – 2018-07-15T08:08:46.387

4

Using an SSH terminal to copy file contents is not the best way. Use an SFTP client to download the file. Or even to edit it directly (if that's the ultimate goal).


Anyway, to answer your question:

  • In PuTTY, while you are connected, go to Change Settings > Windows > Control the scrollback in the window > Lines of scrollback and enter enough lines to fit your whole file.
  • Type cat filename on command prompt.
  • Use the Copy All to Clipboard command.

If there's anything in the "history" of the session already, clear it beforehand:

  • Press Ctrl+L to clear the visible screen.
  • Use the Clear Scrollback command.

You cannot copy a complete contents of a text-based editor, that you see in the PuTTY console.

  • For PuTTY the "screen" is a "black box". It does not know that there's more contents, than it sees.
  • And the remote editor does not have an access to the local clipboard.

Martin Prikryl

Posted 2017-03-07T07:23:23.863

Reputation: 13 764

3

enter image description here

Go to Logging -> do above settings.

Amruth A

Posted 2017-03-07T07:23:23.863

Reputation: 149