Copy the entire content of a file opened in PuTTY to clipboard
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Techno Bleepage Open
--
Chapters
00:00 Copy The Entire Content Of A File Opened In Putty To Clipboard
00:25 Accepted Answer Score 17
00:58 Answer 2 Score 6
01:13 Answer 3 Score 1
02:00 Answer 4 Score 1
02:40 Thank you
--
Full question
https://superuser.com/questions/741526/c...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#putty #copypaste #clipboard
#avk47
ACCEPTED ANSWER
Score 17
You are only able to copy the contents of the currently visible text and the scrollback buffer. For an editor this does not work because it only uses the visible available terminal space to print the file. if you scroll up or down it 'redraws' the visible space with new information.
If you want to copy a large file, run more filename.txt
, go to the end of the file (hit space multiple times) and scroll back in the buffer. You might need to increase the buffer to hold the entire file. This can be done under Settings->Window->Lines of scrollback.
ANSWER 2
Score 6
I keep 2 windows open. One is dedicated to copying. To get a file in the clipboard:
clear
cat {your file}
Then Copy All.
ANSWER 3
Score 1
For files that are too big to fit in the Putty buffer, there aren't many options available.
1- You can increase the number of buffered lines. Go to PuTTY Reconfiguration and select Window. Change the field Lines of scrollback. Then you can display the contents of the file ("cat" command) and copy it. Not a very good solution because it involves a lot of scrolling, uses more memory, and you have to know in advance the number of lines in the file.
2- Don't use the clipboard via Putty; instead copy the file to your computer. The "scp" command can be used for that, or some other alternative such as WinSCP. After that, you can use any text editor, select the whole text, and copy it.
ANSWER 4
Score 1
Building on Dan R's (and others) suggestion:
- Make sure Putty scrollback is set to number of lines in file plus some :
echo $(($(cat <file> | wc -l) + 5)) # (*)
- Clear screen, e.g.:
clear # (*)
- Choose 'Clear Scrollback' in Putty.
- Display file contents of :
cat <file> # (*)
- Choose 'Copy All to Clipboard' in Putty.
- Then paste as desired, trimming first and last lines.
(*) Using bash/ksh and other similar command line interpreters