I open a file in Ubuntu nano editor from the comand line and I want to copy all the contents of the file so I can paste it in an another application outside the shell.

So far I can only copy using shift on the screen that is visible but not on all content.

link|improve this question
Are you in a command line only environment? If not, why don't you open the file in something like gedit? – MBraedley Oct 6 '10 at 10:50
I don't have gedit on that machine and I want to learn to do it in nano. – Elzo Valugi Oct 6 '10 at 14:09
feedback

4 Answers

up vote 3 down vote accepted

You can't use the buffer of nano to use it elsewhere, you need to use the buffer of X or Gnome.

xclip is the solution.

A command line interface to the X11 clipboard. It can also be used for copying files, as an alternative to sftp/scp, avoiding password prompts when X11 forwarding has already been setup.

link|improve this answer
how did this get the check when i clearly submitted the same solution earlier? – aking1012 Oct 20 '10 at 3:12
I think it is more about the story of the buffered that i get the check. I say why it is impossible. But i was spoke about xclip i should have say do what aking1012 suggest sorry. – Louis Oct 22 '10 at 10:50
feedback

Have you tried this:http://www.cyberciti.biz/faq/xclip-linux-insert-files-command-output-intoclipboard/

It isn't within nano, but you could cat the file into xclip with: cat test.txt | xclip

link|improve this answer
feedback

From my understanding it is not possible to select an entire file in nano if it scrolls more then your window. If you are using a GUI and have nano open from a terminal and the file is not longer than your window you can use mouse and select all the text than cnt+shift+c will copy it to clipboard.

Although not in nano, there is a way in vim. See here.

Specifically, select text (visual mode) section.

link|improve this answer
feedback

There is a possible way:

cursor at the beginning of a file, and ctrl-6 to set a mark, then alt-shift-t (or try alt-t) to cut to the end of the file.

This work for me...

link|improve this answer
nice trick, but I wanted a copy not a cut. – Elzo Valugi Jan 18 '11 at 19:41
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.