What is the action of the Bash script that is shown?
A.
The script waits until input is entered. If the directory exists, the script goes into it until there is no directory with the same name, then it creates a new directory.
B.
The script goes into the directory called “$ndir” and makes a new directory called “$ndir”
C.
The script waits unit input is entered, then it goes into the directory entered and creates a new directory with the same name.
D.
For all directories in the current folder. The script goes into directory and makes a new directory.
The Answer Is:
A
This question includes an explanation.
Explanation:
The Bash script shown performs the following actions:
It reads a directory name into the variable ndir.
It enters a loop that continues as long as the directory specified by ndir exists (-d "$ndir" checks if a directory exists).
Inside the loop, it changes the current directory to ndir.
Once the loop exits (when a directory with the name ndir no longer exists), it creates a new directory with the name stored in ndir.
Thus, the script ensures that it continues to navigate into directories with the given name until it finds one that does not exist, and then creates it.
[Reference: Bash Scripting Basics, , , ]
200-901 PDF/Engine
Printable Format
Value of Money
100% Pass Assurance
Verified Answers
Researched by Industry Experts
Based on Real Exams Scenarios
100% Real Questions
Get 65% Discount on All Products,
Use Coupon: "ac4s65"