Copy long single line text with unwanted newlines from terminal


Tim

locate ... | lessOutputs a long path that, while actually a line, appears as multiple lines in the terminal.

I copied the path from the terminal by selecting the text with the mouse and clicking Ctrl+ Shift+ C. When I paste this into a text file, the unwanted changed lines appear in the text exactly as they appear in the terminal.

But I remember long path output locate ... | lessthat can sometimes be copied without introducing unwanted newlines, and sometimes not. I don't know if I do things differently.

So I'm wondering how can I make sure this problem doesn't happen? Thanks!

My OS: Ubuntu 12.04.

My terminal: Gnome Terminal 3.4.1.1

Gilles 'Stop being evil'

Copy the actual text, not what is displayed on the terminal (only what is displayed on the screen). Use one of the external utilities xsel or xclip (they have pretty much the same functionality, I'll use xsel in this answer) to copy data to or from the X clipboard. To copy to the clipboard, pass the desired content on standard input. When pasting from the clipboard, the content is written to standard output.

In less content, |pipe a bunch of wires through a command using a command. Scroll to the first line you want to operate, type mmto set the flag, scroll to the last line, then type |mxsel -band press Enter. Two markers are predefined: ^for the beginning of the file and $for the end of the file. So, to copy the entire file, use <|$xsel -b. To copy a line, use mm|mxsel -band Enter.

Removed -boption to copy to main selection instead of clipboard.

Related


Copy long single line text with unwanted newlines from terminal

Tim locate ... | lessOutputs a long path that, while actually a line, appears as multiple lines in the terminal. I copied the path from the terminal by selecting the text with the mouse and clicking Ctrl+ Shift+ C. When I paste this into a text file, the unwan

Why does single line text have newlines?

shunsuke_stackoverflow I've been using attributed text UILabel. Sometimes the text has line breaks even though the text is a single line.UITableViewCell my code is here if notnullCheck(catchcopy){ //行間 let attributedText = NSMu

Why does single line text have newlines?

shunsuke_stackoverflow I've been using attributed text UILabel. Sometimes the text has line breaks even though the text is a single line.UITableViewCell my code is here if notnullCheck(catchcopy){ //行間 let attributedText = NSMu

Copy from text to text in terminal

Never overlearn I'm new to the community and this is my first question, hope I'm doing it right. My problem: I'm learning some networking and analytics and have a long list of MAC addresses that I want to enter in the same sentence using the command line, but

Copy from text to text in terminal

Never overlearn I'm new to the community and this is my first question, hope I'm doing it right. My problem: I'm learning some networking and analytics and have a long list of MAC addresses that I want to enter in the same sentence using the command line, but

Copy from text to text in terminal

Never overlearn I'm new to the community and this is my first question, hope I'm doing it right. My problem: I'm learning some networking and analytics and have a long list of MAC addresses that I want to enter in the same sentence using the command line, but

Scrolling single line, long text in TextView

Peak See the simple code below. <TextView android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true"

Extract single line from command output in terminal

Sri Hari Vignesh I want to extract the line containing the "seconds time elapsed time" output from the perf stat output of some logging script I'm working on. I don't want to write the output to a file and then search that file. I would like to do it using 'gr

Copy text from one terminal to another

gas I ssh into a university account from my home computer. Then, find the file you want to copy to your local system. So, I opened a new shell terminal and intend to scpcopy it to my system. But the path to the file on the system I'm sshentering is quite long,

Copy text from one terminal to another

gas I ssh into a university account from my home computer. Then, find the file you want to copy to your local system. So, I opened a new shell terminal and intend to scpcopy it to my system. But the path to the file on the system I'm sshentering is quite long,

Reading a line from a text file returns unwanted slashes

Lord Rex I have an application that reads thousands of lines of documents. There is a specific substring in this text file, sometimes starting with "12345" NNNNNNN. The problem is that whenever C# reads the line, it gives me something like "\12345\"NNNNNN. I'v

Reading a line from a text file returns unwanted slashes

Lord Rex I have an application that reads thousands of lines of documents. There is a specific substring in this text file, sometimes starting with "12345" NNNNNNN. The problem is that whenever C# reads the line, it gives me something like "\12345\"NNNNNN. I'v

sed reads a single line, no newlines

Kermit Being new to Linux, I am trying to replace some text strings using sed. The new string is the content of a line of another file. It basically works as expected, except inserting a newline after the replacement text (which I don't want :-) newString=`sed

Copy single line from JUnit fault trace

Merofello Is there a way to replicate a line on a JUnit fault trace in Eclipse? For example, I want to be able to select and copy the second row: Dirk Dean By clicking on the console-icon (see arrow picture), the stack trace will be displayed in the console-vi

Copy single line from JUnit fault trace

Merofello Is there a way to replicate a line on a JUnit fault trace in Eclipse? For example, I want to be able to select and copy the second row: Dirk Dean By clicking on the console-icon (see arrow picture), the stack trace will be displayed in the console-vi

Copy text with newlines to clipboard: Python

Piyush Chauhan I want to copy text with line breaks to clipboard using the following code. import pyperclip numbers='' for i in range(200): numbers = numbers + str(i) + '\n' pyperclip.copy(numbers) After execution, the clipboard should contain: 0 1 2 . .

Copy text with newlines to clipboard: Python

Piyush Chauhan I want to copy text with line breaks to clipboard using the following code. import pyperclip numbers='' for i in range(200): numbers = numbers + str(i) + '\n' pyperclip.copy(numbers) After execution, the clipboard should contain: 0 1 2 . .

Copy text with newlines to clipboard: Python

Piyush Chauhan I want to copy text with line breaks to clipboard using the following code. import pyperclip numbers='' for i in range(200): numbers = numbers + str(i) + '\n' pyperclip.copy(numbers) After execution, the clipboard should contain: 0 1 2 . .

Separating line numbers from text in Terminal: Emacs

username When I run emacs in terminal mode with the global-linum-mode option enabled, the line numbers are very close to my text, which really annoys the eyes. Is there a way to separate line numbers from text in Emacs? Anton Kovalenko Try setting linum-format

Separating line numbers from text in Terminal: Emacs

username When I run emacs in terminal mode with the global-linum-mode option enabled, the line numbers are very close to my text, which really annoys the eyes. Is there a way to separate line numbers from text in Emacs? Anton Kovalenko Try setting linum-format

Separating line numbers from text in Terminal: Emacs

username When I run emacs in terminal mode with the global-linum-mode option enabled, the line numbers are very close to my text, which really annoys the eyes. Is there a way to separate line numbers from text in Emacs? Anton Kovalenko Try setting linum-format

Separating line numbers from text in Terminal: Emacs

username When I run emacs in terminal mode with the global-linum-mode option enabled, the line numbers are very close to my text, which really annoys the eyes. Is there a way to separate line numbers from text in Emacs? Anton Kovalenko Try setting linum-format