I recently asked a question on AskUbuntu (or somewhere else), and a comment or answer asks me to paste the contents of some file or the output of a command to troubleshoot my problem.
How do I do that?
|
I recently asked a question on AskUbuntu (or somewhere else), and a comment or answer asks me to paste the contents of some file or the output of a command to troubleshoot my problem. How do I do that? |
||||
|
|
How to easily share all or part of some text file (or the output of a command)You'll paste the file or command output to Ubuntu's "pastebin" service, and then allow others to look at it by simply sharing a link, or use it yourself to further copy and paste a few lines into your question.
1. Start the terminal
2. Install pastebinit, a small tool to paste text from the terminal
3. Pastebin the file or command and paste its URL on AskUbuntu
4. Paste the link into your AskUbuntu question/comment
5. Optional: View your pastebin link, and only paste selected lines from it into your AskUbuntu
Alternate way to pastebin a file using an editorThis may be useful if you are having a problem with Software Center, Update Manager or
|
|||||
|
|
Usually, bash has a utility called "script" that creates a sub-terminal that writes to file. For example, if you do:
It will create a new bash prompt, and all input and output will be stored in the file ask-ubuntu.txt when you exit the sub-shell. You can then obviously copy the contents of the file, or upload the file, wherever you need it. |
|||||
|
|
|
Another option, if you don't necessarily want to share the output on Pastebin, is to use xclip. It takes what you give it on the standard input and puts it in the X selection. To get
To copy the output of a command,
To copy the contents of a file,
And to paste whatever you copied, just click the middle mouse button over the textbox you want it in. |
||||
|
|
|
I may have missed something in the excellent answers above, but if what you want to copy is relatively small, all you have to do is get it displayed on your screen (e.g. cat filename in a terminal or opening the file in a editor), highlight the desired text with the mouse and copy it into your clipboard. Once there, you can just paste it into your reply on the web or into an email, etc. Using pastebin or pre tags is important with longer material so that it gets separated out from the rest of the question/answer so that it doesn't distract people from the rest of the post. |
|||
|
|
|
I may have misunderstood the question, but I've found that in the terminal you can use the following after selecting what needs to be copied with your mouse:
Obviously once in AskUbuntu or whatever forum with your browser you use your regular Ctrl + C and Ctrl + V. This might be a new addition in 12.04 seeing as I'm a relatively new user and noone else seems to have mentionned it beforehand, but to me this seems an easier and quicker option rather than having to install software or running command lines, especially for relatively new users. Hoping this helps complement Izx's incredibly complete answer. |
||||
|
|