Which command will copy two files ending in .txt to the /tmp/ directory?

Prepare for the LPI Linux Essentials 010-160 Test. Study with flashcards and multiple choice questions, each question offers hints and explanations. Get ready to ace your exam!

The command that successfully copies files ending in .txt to the /tmp/ directory is constructed using the wildcard character *, which represents any number of characters. This functionality allows users to select multiple files that fit a certain pattern—in this case, all files ending with the .txt extension.

When using cp *.txt /tmp/, the shell expands *.txt to match all files in the current directory that have the .txt suffix. Thus, if there are two or more such files present, they will all be copied to the specified /tmp/ directory. This command is essential for bulk file operations, enabling efficient management of multiple files with a single command.

Other options provided do not achieve the desired outcome. The first option assigns a specific file named 'all.txt' to the /tmp/ directory, which does not fulfill the requirement of copying files with the .txt extension. The third option mistakenly uses the copy command, which is not a standard command in Linux; the correct command is cp. Finally, the fourth option employs the mv command, which is used to move files rather than copy them, resulting in the originals being removed from their current location.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy