13

There is a way to put some command output to system clipboard via xclip.

some-command | xclip -selection clipboard 

I'd like to perform a reverse task - Print system clipboard to terminal. How it can be done?

1

2 Answers 2

12

According to the manpage the -o option to xclip shoves data in the opposite direction:

 -i, -in read text into X selection from standard input or files (default) -o, -out prints the selection to standard out (generally for piping to a file or program) 

In your above command, the -i is being assumed.

6

Another choice is the xsel program:

By default, this program outputs the selection without modification if both standard input and standard output are terminals (ttys). Other‐ wise, the current selection is output if standard output is not a ter‐ minal (tty), and the selection is set from standard input if standard input is not a terminal (tty). If any input or output options are given then the program behaves only in the requested mode. 

So, just copy something to the clipboard and run xsel to print it to the terminal. You can have a read through man xsel for more advanced options like which clipboard should be used etc.

1
  • 6
    To simplify things ... this is what I do: alias pbcopy='xsel --clipboard --input'; alias pbpaste='xsel --clipboard --output' I chose the names to match the MacOS commands. Commented Apr 21, 2014 at 18:51

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.