010-160 Exam QuestionsBrowse all questions from this exam

010-160 Exam - Question 39


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?

Show Answer
Correct Answer: B

To copy files that end with .txt to the /tmp/ directory, the command cp *.txt /tmp/ is the correct command. The asterisk (*) is a wildcard character that matches any number of characters. Therefore, *.txt will match all files in the directory that have a .txt extension, including texts 1.txt and texts 2.txt.

Discussion

6 comments
Sign in to comment
StylesOption: B
Feb 25, 2020

*. txt means all the txt files

sasquatchshrimpOption: B
Dec 13, 2020

B is the correct answer. the "*" is a "wildcard" meaning it looks for anything with .txt at the end.

NunjaminOption: D
Jan 27, 2020

cp ?.txt /tmp/ would also copy the two .txt files wouldn't it?

WaldoWhereAmI
Feb 22, 2020

No ? = Matches up exactly one character

Jay987654Option: B
Dec 27, 2023

The correct answer is B! B - "cp *.txt /tmp/" is the command for copying all files ending in ".txt" to the "/tmp/" directory. This is a wildcard match, which means that any file in the current directory with a ".txt" extension will be copied.

emigrin14Option: D
Sep 25, 2023

Both B and D results in the same solution. Considering both 1.txt and 2.txt has exactly one character before ".txt", the question mark ? in answer D results in matching those two files in the resolution. That being said, the aserisk * in answer B also matches AT LEAST 1 character before ".txt".

TacosInMyBellyOption: B
Nov 30, 2023

As stated before, "*" selects all .txt files, while "?" is for exactly one character such as "1.txt"