Given:
file1 and file2 are text files.
dir1 and dir2 are directories.
Which two commands will be successful?
A.
cp dir1 dir1
B.
cp dir1 file1
C.
cp file? dir1
D.
cp file. dir1
E.
cp file% dir2
F.
cp file1 file2 dir1
Explanation:
C: Here the wildcard character ? is used (Matches any single character).
file1 and file2 will be copied into dir1
F: the two files file1 and file2 are copied into directoy dir1.
Note: cp – copy files and directories
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
Cp has three principal modes of operation. These modes are inferred from the type and count of argumentspresented to the program upon invocation.
* When the program has two arguments of path names to files, the program copies the contents of the first file
to the second file, creating the second file if necessary.
* When the program has one or more arguments of path names of files and following those an argument of a
path to a directory, then the program copies each source file to the destination directory, creating any files not
already existing.
* When the program’s arguments are the path names to two directories, cp copies all files in the source
directory to the destination directory, creating any files or directories needed. This mode of operation requires
an additional option flag, typically r, to indicate the recursive copying of directories. If the destination directory
already exists, the source is copied into the destination, while a new directory is created if the destination does
not exist.