I would like to copy files with multiple extensions to a single destination directory.
For example, I can use the following command to copy all .txt files in the working directory to a directory called destination:
cp -v *.txt destination/
And I can use the following to copy all .png directories in the working directory to destination:
cp -v *.png destination/
But it's time consuming to type these as separate commands (even with the use of command history). So, is there any way that I can tell cp to copy files with either the pattern *.txt or the pattern *.png to destination? Ideally, I would like to be able to specify more than two patterns -- like instructing cp to copy all *.txt or *.png or *.jpg files to destination, for example.
I'm sure that all of this is possible using a shell script -- I'm using bash, for example -- but is there any way to accomplish it more simply, just from the console? Could I somehow use brace expansion to do it?
I know that it is possible to copy all files in the working directory except those matching certain specified patterns, but since my working directory contains far more file extensions that I don't want to copy than those I do, that would be a pain.
Do you have any thoughts on this?
cp -v *.txt *.png destination/?