Free LPI 102-500 Actual Exam Questions - Question 10 Discussion
____ i in *.txt; do
echo $i
done
A makes sense because 'for' is the standard keyword for this pattern.
A, cause only 'for' fits iterating over files like that.
It’s A for sure. The structure “i in *.txt; do” is a giveaway that it’s a for loop. B, C, and D don’t match that pattern at all. The “loop” keyword doesn’t even exist in shell scripts, and “while” or “until” wouldn’t use “in *.txt” like that. This is basic shell looping syntax you see all the time when iterating over file lists.
Guessing A since only 'for' pairs with 'i in *.txt' correctly here.
This one’s definitely A since the “for … in” syntax is classic for looping over files or items in shell scripts. None of the other keywords (B, C, D) fit with the “in *.txt” part. Also, the rest of the code uses “do” which pairs with “for” loops, not while or until loops. So yeah, missing keyword is for (A).
A imo, only 'for' fits the 'i in' pattern in standard shell scripts.
A, because only 'for' works with the 'i in' loop syntax in shell scripts.
A. The pattern "i in *.txt; do" clearly matches the syntax for a for loop in most shell scripts. The others don’t fit here because "loop" isn’t a shell keyword, and "while" or "until" loops use different syntax without "in". So, without overcomplicating, “for” is the missing keyword that makes this code work as intended.
Can't be B, C, or D since only "for" fits the "i in" pattern here.
D imo, none of the other options fit the “i in” syntax except for a “for” loop. “While” or “until” wouldn’t be followed by “i in *.txt” like that.
A for sure, since “i in” requires a “for” loop syntax here.
A vs C? Until loops don’t use “in” either, so that rules out C. The only keyword that fits “i in *.txt; do” is definitely A. for.
A. The structure with "i in *.txt; do" is classic for-loop syntax in shell scripts. “While” loops don’t use the “in” keyword, and “loop” isn’t a shell keyword at all. “Until” also doesn’t fit here since it’s for condition-based looping, not iterating over a list. So the missing keyword has to be “for”.
This one’s definitely A. The pattern “i in *.txt; do” only makes sense with a for loop. While loops don’t use the “in” keyword like this, and “loop” isn’t a valid shell keyword anyway. So the missing word has to be for.
A. The code clearly follows the standard for-loop syntax in shell scripts: for variable in list; do commands; done. None of the other options fit this structure. While the semicolon before done is important if everything’s on one line, the missing keyword itself is definitely “for.”
Maybe D, but I’m pretty sure it’s not while because the pattern "in *.txt" is typical with for loops. Since the question asks for a missing keyword, and the structure is "____ i in *.txt; do ... done", it’s almost always for. While loops don’t use "in" like that. So D doesn’t really make sense here, which kind of confirms that A is the best fit.
It can't be B/C/D because loop/until/while don't fit the syntax here.
A this looks like a classic for loop in shell scripts