Glam Prestige Journal

Bright entertainment trends with youth appeal.

If I do echo foo | xclip -i in the terminal and then Ctrl + V, I get foo.

But instead, if I write a file,

bar.sh

#!/bin/sh
echo bar | xclip -i

and run ./bar.sh in the terminal, the clipboard content doesn't become "bar" as I would expect.

Why? And how do I make it do to so?

I managed to do it changing the line echo bar | xclip -i to echo bar | xclip -selection c, but why does this way work and the other doesn't?

1 Answer

When you use the command

echo bar | xclip -i

xclip stores the text in its primary register, which is accessible with the middle mouse button. from man xclip

-selection
specify which X selection to use, options are "primary" to use XA_PRIMARY (default), "secondary" for XA_SECONDARY or "clipboard" for XA_CLIPBOARD

When you use

echo bar | xclip -selection c

bar is being captured in xclip's clipboard register - I'm guessing c is an alias for clipboard.
Its strange the echo bar | xclip -i then Ctrl + v command worked - It doesnt for me. I wonder if you had foo in your clipboard from a previous command?

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy