0

Let's say I have an alias on my system which I often use to tell me my system information, the alias is systeminfo, and it executes lsb_release -a which outputs:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 15.04
Release:    15.04
Codename:   vivid

Now because I use this very often, and I then copy and paste the information into my AskUbuntu questions, it would be very useful if upon execution of the command, for the output to not only be printed to the Terminal window, but also be copied to my system clipboard, so that I can save time, and not need to select the text and then copy and paste that here. So I was wondering how that could be achieved? How do I make it so that not only is it printed on screen, but also copied to the system clipboard? Preferably, I would like this question to be answered with a script which asks me if I want the information to be copied to my system clipboard in addition to being displayed on screen, but I can of course write up that script, so it would just be for convenience and to save time.

Information Update:

I have tried these, but they don't work for me:

1 Answers1

1

You can install xsel

sudo apt-get install xsel

Then run

cat /etc/lsb-release | xsel -ib

And

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.2 LTS"

will be copied to clipboard.

You can also output text from clipboard to a terminal command by e.g.

xsel -ob | cat
Pilot6
  • 90,100
  • 91
  • 213
  • 324
  • Just as additional info, if you need the clipboard content as input to a terminal command, you do e.g. xsel -ob | cat to pipe the clipboard content to cat and print it to standard out. Note the -o instead of -i which means "output" in contrast to "input". – Byte Commander Aug 03 '15 at 19:18
  • I will add it. Thx. – Pilot6 Aug 03 '15 at 19:19