Remove the temporary directory work and its files.
The directory was created by you and contains only writable regular files.
Which command specifies recursive removal?
rm -r recursively removes a directory and its contents. Confirm the target carefully because a wrong path can cause extensive damage.
Detailed explanation
rm workIncorrect. rm without -r does not remove a non-empty directory.
Incorrect. rm without -r does not remove a non-empty directory.
rmdir -p workIncorrect. rmdir removes empty directories and does not recursively delete files.
Incorrect. rmdir removes empty directories and does not recursively delete files.
rm -d workIncorrect. -d is not the normal recursive directory-removal option.
Incorrect. -d is not the normal recursive directory-removal option.
rm -r workCorrect. rm -r work recursively removes the directory tree.
Correct. rm -r work recursively removes the directory tree.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); mkdir "$tmp/work"; touch "$tmp/work/item"; rm -r "$tmp/work"; test ! -e "$tmp/work" && echo removed; rmdir "$tmp"Expected result
removedKey points
- -r means recursive
- rmdir requires empty
- Confirm the target path
Notes
- Environment: GNU coreutils 9.x / 自分が所有する一時ディレクトリ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.