Limitless

Limitless

How to Copy To Clipboard in Terminal

How to Copy To Clipboard in Terminal

Subscribe to my newsletter and never miss my upcoming articles

Use the x-clip package to copy the content of a file to your clipboard from your the terminal. We'll go over the steps to achieve this.

Steps

  1. Create a file lorem.txt and populate it with lorem-ipsum
    cat > lorem.txt << EOF
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Incidunt debitis magnam
    provident nam cum alias nisi suscipit perspiciatis veritatis? Assumenda.
    EOF
    
  2. Install xclip
    sudo apt install xclip
    
  3. Select the file using xclip -sel c < filename
    xclip -sel c < lorem.txt
    
    -sel refers to selection and c refers to clipboard. You can run xclip -h for more info.
  4. Check the content of your clipboard
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Incidunt debitis magnam
    provident nam cum alias nisi suscipit perspiciatis veritatis? Assumenda.
    

For more tutorials and tips like this, subscribe to my newsletter. Thanks for reading. Adios.

#linux#ubuntu#tips#tutorial
 
Share this