Which of the following examples shows the general structure of a for loop in a shell script?
Which of the following examples shows the general structure of a for loop in a shell script?
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.
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.
C is the correct answer