200-901 · Question #71
Refer to the exhibit. What is the action of the Bash script that is shown?
The correct answer is A. The script waits until input is entered. If the directory exists, the script goes into it until there is no. Based on the described behavior and correct answer, the Bash script uses a read command to wait for user input (capturing a directory name), then checks whether that directory exists (likely using an if/while construct with a condition like [ -d "$ndir" ]). If the directory is…
Question
Refer to the exhibit. What is the action of the Bash script that is shown?
Options
- AThe script waits until input is entered. If the directory exists, the script goes into it until there is no
- BThe script goes into the directory called "$ndir" and makes a new directory called "$ndir"
- CThe script waits unit input is entered, then it goes into the directory entered and creates a new
- DFor all directories in the current folder. The script goes into directory and makes a new directory.
How the community answered
(58 responses)- A93% (54)
- B2% (1)
- C3% (2)
- D2% (1)
Explanation
Based on the described behavior and correct answer, the Bash script uses a read command to wait for user input (capturing a directory name), then checks whether that directory exists (likely using an if/while construct with a condition like [ -d "$ndir" ]). If the directory is found, the script changes into it. The loop continues prompting for input until no valid directory is entered or input ends. This is a common interactive directory navigation pattern in Bash scripting.
Topics
Community Discussion
No community discussion yet for this question.