Copying multiple specific files from one folder to another

Copying multiple specific files from one folder to another

There are several ways you could achieve this. The easiest I have seen is to use the following.
cp /home/usr/dir/{file1,file2,file3,file4} /home/usr/destination/

cp /home/usr/dir/{file1,file2,file3,file4} /home/usr/destination/


The syntax uses the cp command followed by the path to the directory the desired files are located in with all the files you wish to copy wrapped in brackets and separated by commas.

Make sure to note that there are no spaces between the files. The last part of the command, /home/usr/destination/, is the directory you wish to copy the files into.

or if the all the files have the same prefix but different endings you could do something like this:
cp /home/usr/dir/file{1..4} ./

Where file1,file2,file3 and file4 would be copied.

Leave a Reply