4

I need to copy all text in large log files to clipboard. I have a remote connection to Linux and use the console terminal only. What I want is something like Select all -> Copy.

In emacs I used F10 -> Edit -> Select All, and then F10 again -> Edit -> Copy. But it didn't go to my clipboard, unable to paste it in my local windows instance (which works fine with the content displayed on screen; without scrolling).

Is there a better way in nano or emacs?

Cheers

CRUSADER
  • 5,486
  • 3
  • 28
  • 64
gorn
  • 8,097
  • 5
  • 37
  • 44

2 Answers2

4

Emacs has a very under-publicized capability that could make your life easier. You can actually open files remotely via ssh, just as easily as a local file, and with very little overhead. So as long as you can copy to clipboard from your local emacs, you can do what you need.

To open a file remotely, just hit C-x C-f as usual. But the file you want is something like

/ssh:otherserver.some.org:/path/to/file.log

where otherserver.some.org is replaced by the actual server name and /path/to/file.log is your actual path. After the first connection, tab completion also works. Editing works exactly as it does with a local file (including copying), except that when you save, the file is copied back to the remote via ssh.

This facility is called "TRAMP", so there will be hidden buffers with "tramp" in their names. Also note that tramp can use several other methods to connect to files, such as plink for Windows, and su to edit files as another user.

Other options for your problem are discussed here: Getting Items on the Local Clipboard from a Remote SSH Session, or maybe even here: http://winscp.net/eng/docs/task_edit.

Community
  • 1
  • 1
Mike
  • 19,114
  • 12
  • 59
  • 91
-1

If you have just a terminal session, then there is no way for emacs, nano or any other program running on the Linux side to send text to the Windows clipboard.

Your options are to connect by X11 or VNC, in which case it becomes possible to share a clipboard between Windows and Linux programs, or to copy the file by some other means.

If you are logging in by ssh, you could for example run ssh thelinuxmachine cat /the/log/file/locatioin > logfile.txt in a windows command shell. Connecting to the linux machine using an scp client such as http://winscp.net/ would probably also work.

slowdog
  • 6,076
  • 2
  • 27
  • 30