010-160 Exam QuestionsBrowse all questions from this exam

010-160 Exam - Question 66


Which of the following examples shows the general structure of a for loop in a shell script?

Show Answer
Correct Answer: C

The general structure of a for loop in a shell script involves using the 'for' keyword followed by a variable, the 'in' keyword, and the list to iterate over. It includes the 'do' and 'done' keywords to enclose the block of commands to execute for each item in the list. The correct format is: for variable in list; do commands; done. The option 'for file in *.txt do echo $i done' closely matches this structure.

Discussion

2 comments
Sign in to comment
sasquatchshrimpOption: C
Dec 13, 2020

This is correct. It would be easier if there was proper spacing, but I believe they are looking for the do and done, which makes the other answers wrong.

beazzlebubOption: C
Jul 26, 2021

C is the correct answer