• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

xclip Command Examples in Linux

by admin

Linux provides a command, xclip, that connects X selections to stdin and stdout. You can therefore insert copy and paste operations into pipelines and other combined commands. For example, you may have copied text into an application like this:

  • Run a Linux command and redirect its output to a file.
  • View the file.
  • Use your mouse to copy the file’s content to the clipboard.
  • Paste the content into another application.

With xclip, you can shorten the process considerably:

  • Pipe a Linux command’s output to xclip.
  • Paste the content into another application.

xclip Command Examples

1. Copy the output from a command to the X11 primary selection area (clipboard):

# echo 123 | xclip

2. Copy the output from a command to a given X11 selection area:

# echo 123 | xclip -selection primary|secondary|clipboard

3. Copy the output from a command to the system clipboard, using short notation:

# echo 123 | xclip -sel clip

4. Copy the contents of a file into the system clipboard:

# xclip -sel clip input_file.txt

5. Copy the contents of a PNG into the system clipboard (can be pasted in other programs correctly):

# xclip -sel clip -t image/png input_file.png

6. Copy the user input in the console into the system clipboard:

# xclip -i

7. Paste the contents of the X11 primary selection area to the console:

# xclip -o

8. Paste the contents of the system clipboard to the console:

# xclip -o -sel clip

Filed Under: Linux

Some more articles you might also be interested in …

  1. “git force-clone” Command Examples
  2. aws ecr – Push, pull, and manage container images (Command Examples)
  3. Linux OS Service ‘cpuspeed’
  4. fstrim: command not found
  5. iptables Command Examples in Linux
  6. kitty Command Examples
  7. mate-dictionary Command Examples
  8. certutil: Manage keys and certificates in both NSS databases and other NSS tokens
  9. Sa Command Examples in Linux
  10. apport-bug: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright