200-901 · Question #490
Refer to the exhibit. A development team is creating a Python application. After several days of work, a developer notices several pycache folders and creates a Bash script to clean up the folders. Wh
The correct answer is A. Recursively delete all the __pycache__ folders.. The Bash script uses the 'find' command to recursively locate and delete all __pycache__ directories throughout the project tree.
Question
Refer to the exhibit. A development team is creating a Python application. After several days of work, a developer notices several pycache folders and creates a Bash script to clean up the folders. What being automated by the Bash script?
Options
- ARecursively delete all the pycache folders.
- BFind all the empty pycache folders and delete them.
- CDelete all the files in the pycache folders.
- DFind all the files named PWD and delete them.
How the community answered
(35 responses)- A89% (31)
- B6% (2)
- C3% (1)
- D3% (1)
Why each option
The Bash script uses the 'find' command to recursively locate and delete all __pycache__ directories throughout the project tree.
The script executes a command such as 'find . -type d -name __pycache__ -exec rm -rf {} +', which traverses the entire directory tree from the current path, matches every directory named '__pycache__', and removes each one along with all of its contents. This handles nested occurrences at any depth within the project structure, making the deletion fully recursive.
The 'rm -rf' portion of the command removes non-empty directories, not just empty ones; the script does not use '-empty' or equivalent flags to restrict deletion to only empty directories.
The find command targets directories ('-type d') named '__pycache__' and removes them entirely with 'rm -rf', which deletes both the directory and all files inside it, not just the files while leaving the directory intact.
The script searches for directories named '__pycache__', not files named 'PWD'; PWD is a standard shell environment variable holding the current working directory path and is unrelated to this script.
Concept tested: Bash find and rm -rf for recursive directory cleanup
Source: https://www.gnu.org/software/findutils/manual/html_mono/find.html
Topics
Community Discussion
No community discussion yet for this question.