JavaScript is required

Để sao chép tất cả nội dung có trong thư mục /dir vào thư mục /tmp, thi hành lệnh:

A.

cp –r /dir/* /tmp

B.

cp –a /dir/* /tmp

C.

cp --parents /dir/* /tmp

D.

Tất cả đều đúng

Trả lời:

Đáp án đúng: D


The question tests knowledge of the `cp` (copy) command in Linux/Unix and its options for recursively copying directories. `cp -r /dir/* /tmp`: The `-r` (recursive) option allows recursive copying of directories. `/dir/*` specifies all files and subdirectories directly within /dir. However, it will not copy the /dir directory itself. `cp -a /dir/* /tmp`: The `-a` (archive) option is equivalent to `-dR --preserve=all`. It preserves all file and directory attributes (permissions, timestamps, etc.) and also copies recursively. Similar to option A, it doesn't copy the /dir directory. `cp --parents /dir/* /tmp`: The `--parents` option creates parent directories for each filename argument. However, it recreates the directory structure from the root directory, rather than just copying the /dir directory. Furthermore, it also does not copy the /dir directory. Since none of the options fully copy the /dir directory into /tmp, none of the answers is completely correct. However, answers A and B are the closest because they copy the contents of /dir into /tmp. In this case, if you wanted to copy the /dir directory into /tmp, the correct command would be `cp -r /dir /tmp` (without the /*). Since no answer is completely correct, we will consider the closest answer. Therefore, the most correct answer among the choices is A or B. The best command would be cp -r /dir /tmp

Câu hỏi liên quan