That's a very important question when working with cp!
Let's consider the two main scenarios with cp when the destination doesn't exist:
Scenario 1: Copying a File to a Non-existent Directory
You're trying to copy file2.txt to testdir/, but imagine testdir does not exist at all.
cp file2.txt non_existent_directory/
In this case, the cp command will fail and give you an error message, something like:
cp: cannot create regular file 'non_existent_directory/file2.txt': No such file or directory
This means cp cannot create the non_existent_directory for you automatically when you're trying to copy into it. You would need to create the directory first using mkdir non_existent_directory and then run the cp command.
Scenario 2: Copying a File to a Non-existent File Name (creating a new file)
If you are copying a file to a new file name that doesn't exist (like cp file1.txt file1_copy.txt), and file1_copy.txt doesn't exist, cp will simply create it. This is how you make a copy!
Scenario 3: Copying a Directory to a Non-existent Directory Name (like in cp -r testdir testdir_copy)
In the command cp -r testdir testdir_copy, if testdir_copy does not exist, cp will create a new directory named testdir_copy and then copy all the contents of testdir into it. This is exactly how you make a copy of an entire directory!
So, the key takeaway is that cp generally won't create intermediate directories for you if you're trying to copy a file into a path that doesn't exist. However, it will create a new file or a new top-level directory if the destination name suggests it.
Does that distinction make sense?