To copy specific files, you can use the cp command followed by the names of the files you want to copy and the destination directory. Here’s how to do it:
Syntax:
cp file1.txt file2.txt /path/to/destination_directory/
Example:
Suppose you have the following files in your current directory:
file1.txtfile2.txtfile3.txt
If you want to copy file1.txt and file2.txt to a directory called backup, you would use:
cp file1.txt file2.txt backup/
Notes:
- Ensure that the destination directory (
backupin this case) exists; otherwise, the command will fail. - You can also use wildcards to copy files that match a pattern. For example, to copy all
.txtfiles:
cp *.txt /path/to/destination_directory/
Let me know if you need more details or examples!
