Suppose you have different files in a directory: one.txt, two.jpg, three.pdf, four.jpg etc. You want to copy them all to clipboard from the command line. Something like copyclipboard *. How do you do it?

Based on this answer, which solves for a particular case, but has the filetype hardcoded in the script. I wonder if there is a more general solution.

2 Answers 2


In fact, the command I posted in the original question was applicable to a wide range of situations:

find ${PWD} -name "*.pdf"| xclip -i -selection clipboard -t text/uri-list

the only requirement is for the first command (find in this case) to generate a list of absolute filenames to files which need to be copied. If you check man find, you'll see that you can modify the command to find files created later than particular date, larger than particular size, having particular permissions, matching a particular regexp etc.

If you want to have a short-cut command for a particular use case - e.q. copying files from the current directory and below matching a particular mask, you can write a short script:

find "$PWD" -name "$1" | xclip -i -selection clipboard -t text/uri-list

and call it with

cb "*.txt"

(where cb is the name of the script)


Is this to speed up some workflow you have or for some script?

What I usually do is that when I enter the folder with the files I want to copy I run nautilus . to get the file browser. The workflow problem I see with copying straight from terminal is that you still need to browse to the folder where you want to paste the files later on.

Please comment if I'm missing something here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.