Most Linux applications including terminals support quick copying and pasting using a mouse. Simply click and drag over some text with the left button, and as soon as you lift your finger the selection will be copied into what is called the “primary selection,” where it stays until you select something else. You can then middle–click to paste the selection in basically any application.

Left–clicking and dragging as above selects one character at a time. You can also select a word or line by double- or triple–clicking, respectively, and select multiples by holding down the mouse button after the last click and dragging.

A “line” in this case really means up to and including a newline character or “hard” line break in the terminal backlog, and not what is called a “soft” line break caused by a long line overflowing to the next in your terminal. Soft line breaks are not part of the terminal backlog, and so will not be part of any text you copy. The difference becomes obvious if you resize the terminal: soft line breaks are introduced when the width is lowered, but disappear when you make the terminal wide enough to fit up to the hard line break.


This page is a preview of The newline Guide to Bash Scripting

Please select a discussion on the left.