Linux Essentials (010-160) — Question 2
A directory contains the following three files:
texts 1.txt
texts 2.txt
texts 3.csv
Which command copies the two files ending in .txt to the /tmp/ directory?
Answer options
- A. cp ??.txt /tmp/
- B. cp *.txt /tmp/
- C. cp. \.txt /tmp/
- D. cp ?.txt /tmp/
- E. cp $?.txt /tmp/
Correct answer: B
Explanation
The correct answer is B because the wildcard *.txt matches all files that end with .txt, which are texts 1.txt and texts 2.txt. Option A is incorrect as ??.txt would only match files with exactly two characters before .txt, which does not apply here. Options C, D, and E contain syntax errors or incorrect wildcard usage, making them invalid for this task.