nerdexam
Cisco

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.

Software Development and Design

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)
  • A
    89% (31)
  • B
    6% (2)
  • C
    3% (1)
  • D
    3% (1)

Why each option

The Bash script uses the 'find' command to recursively locate and delete all __pycache__ directories throughout the project tree.

ARecursively delete all the __pycache__ folders.Correct

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.

BFind all the empty __pycache__ folders and delete them.

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.

CDelete all the files in the __pycache__ folders.

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.

DFind all the files named PWD and delete them.

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

#Python#Bash scripting#File system operations#Project cleanup

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice