Play this article
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
- 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
- Install xclip
sudo apt install xclip
- Select the file using
xclip -sel c < filename
xclip -sel c < lorem.txt
-sel
refers to selection andc
refers to clipboard. You can runxclip -h
for more info. - 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.
ย