If you are using the X11 window system (and it's clipboard), you can use xclip
to access the clipboard from command line:
paste
:
xclip -o # Write clipboard's contents to stdout
VARIABLE=$(xclip -o) # Write clipboard's contents into a variable
xclip -o | command # Pipe clipboard contents into command's stdin
copy
:
xclip -i "Some text" # Save static text in the clipboard
xclip -i $(command) # Save the output of a command into clipboard
command | xclip -i # Same as above but with a pipe
Note: xclip
will probably not getting installed along with the default X11 installation, you'll need to install it explicitly then.