How to copy specific files?

QuestionsQuestions8 SkillsProBasic Files OperationsSep, 29 2025
0148

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.txt
  • file2.txt
  • file3.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 (backup in 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 .txt files:
cp *.txt /path/to/destination_directory/

Let me know if you need more details or examples!

0 Comments

no data
Be the first to share your comment!