Recall & Review
beginner
What does the
-exec option do in the find command?It allows you to run a command on each file that
find locates. This means you can perform actions like deleting, moving, or printing files directly from find.Click to reveal answer
beginner
How do you correctly end a command used with
-exec in find?You end the command with
\;. This tells find where the command finishes.Click to reveal answer
beginner
What does
{} represent in the find -exec command?It is a placeholder for the current file found by
find. The command replaces {} with the file name.Click to reveal answer
intermediate
Why might you use
find . -name '*.txt' -exec rm {} \;?This command finds all files ending with
.txt in the current directory and deletes each one by running rm on them.Click to reveal answer
intermediate
What is the difference between
-exec command {} \; and -exec command {} + in find?Using
\; runs the command once per file. Using + runs the command once with all files as arguments, which can be faster.Click to reveal answer
What symbol ends the command in
find -exec?✗ Incorrect
The command must end with a backslash and semicolon (\;) to tell find where the command ends.
In
find . -exec ls -l {} \;, what does {} do?✗ Incorrect
{} is replaced by each file found by find.Which command deletes all
.log files in the current directory and subdirectories?✗ Incorrect
Option C uses
find with -exec rm to delete each .log file found.What is the benefit of using
-exec command {} + over -exec command {} \;?✗ Incorrect
Using
+ runs the command once with all files, which is more efficient.Which of these is a correct way to move all
.txt files to a folder named backup?✗ Incorrect
Option A correctly uses
find with -exec mv to move each .txt file to backup.Explain how the
-exec option works in the find command and how to use it safely.Think about how you tell find what to do with each file it finds.
You got /4 concepts.
Describe the difference between ending
-exec with \; and + and when to use each.Consider performance and command compatibility.
You got /4 concepts.