1

In bash, I can type Ctrl+u it "cuts" text behind my cursor.

Then when I press Ctrl+y it pastes the text back.

Is there a file where the cut text is stored?

Drew LeSueur
  • 19,185
  • 29
  • 89
  • 106

2 Answers2

2

The "clipboard" -- actually called the kill ring -- is implemented by the readline library. It is not persistent, so it is not saved in a file.

There are lots of keystroke commands for "kill"ing and "yank"ing text, which are described in the bash manual:

Killing text means to delete the text from the line, but to save it away for later use, usually by yanking (re-inserting) it back into the line. (‘Cut’ and ‘paste’ are more recent jargon for ‘kill’ and ‘yank’.)

More complete documentation is in this section of the manual.

rici
  • 234,347
  • 28
  • 237
  • 341
1

xsel can copy and paste to three different "clipboards". By default, it uses the X Window System primary selection, which is basically whatever is currently in selection. The X Window System also has a secondary selection (which isn't used much), and a clipboard selection. You're probably looking for the clipboard selection, since that's what the desktop environment (e.g. Gnome, KDE, XFCE) uses for its clipboard. To use that with xsel:

xsel --clipboard < new-clipboard-contents.txt
xsel --clipboard > current-clipboard-contents.txt

or use this link

DolDurma
  • 15,753
  • 51
  • 198
  • 377