nerdexam
Linux_Foundation

LFCS · Question #534

What keyword is missing from this code sample of a shell script? ____ i in *.txt; do echo $i done

The correct answer is A. for. The missing keyword in the shell script code sample for iterating over files is for, used to construct a for loop.

Submitted by viktor_hu· Apr 18, 2026Essential Commands

Question

What keyword is missing from this code sample of a shell script? ____ i in *.txt; do echo $i done

Options

  • Afor
  • Bloop
  • Cuntil
  • Dwhile

How the community answered

(35 responses)
  • A
    91% (32)
  • B
    3% (1)
  • C
    6% (2)

Why each option

The missing keyword in the shell script code sample for iterating over files is `for`, used to construct a `for` loop.

AforCorrect

In shell scripting, `for i in *.txt; do echo $i; done` is the standard syntax for a `for` loop that iterates through all files matching the pattern `*.txt`, assigning each filename to the variable `i` for processing within the loop's `do...done` block. The `for` keyword introduces this iterative control structure.

Bloop

`loop` is not a standard keyword for creating iterative loops in bash scripting; it is often part of a loop's description, not its syntax.

Cuntil

`until` is a keyword used for a loop that continues until a condition becomes true, with a different syntax (`until condition; do commands; done`).

Dwhile

`while` is a keyword used for a loop that continues as long as a condition is true, also with a different syntax (`while condition; do commands; done`).

Concept tested: Bash `for` loop syntax

Source: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Looping-Constructs

Topics

#shell scripting#for loop#bash syntax#iteration

Community Discussion

No community discussion yet for this question.

Full LFCS Practice