nerdexam
LPI

117-102 · Question #756

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. Exam Questions, Study Guides, Practice Tests. Lead the way to help you pass any IT Certification exams, 100% Pass Guaranteed or Full Refund. Especially Cisco, CompTIA, Citrix, EMC, HP, Oracle, VMware, Juniper, Check Point, LPI, Nortel, EXIN and so on. Our Slogan: First Test…

105 Shells, Scripting and Data Management

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

(60 responses)
  • A
    78% (47)
  • B
    12% (7)
  • C
    7% (4)
  • D
    3% (2)

Explanation

Exam Questions, Study Guides, Practice Tests. Lead the way to help you pass any IT Certification exams, 100% Pass Guaranteed or Full Refund. Especially Cisco, CompTIA, Citrix, EMC, HP, Oracle, VMware, Juniper, Check Point, LPI, Nortel, EXIN and so on. Our Slogan: First Test, First Pass. Help you to pass any IT Certification exams at the first try. You can reach us at any of the email addresses listed below. Any problems about IT certification or our products, you could rely upon us, we will give you satisfactory answers in 24 hours.

Topics

#shell scripting#for loop#bash syntax#glob pattern

Community Discussion

6
Yusuf A.Yusuf A.Jun 20, 2026

The answer is A, for. That construct, "for i in *.txt", is the standard Bash way to loop over a list of items, in this case every .txt file in the current directory, and run the echo command on each one.

18
Mateus R.Mateus R.Jun 23, 2026

Yusuf is right that A is the answer, but worth adding that the "for...in" loop here works exactly like sorting mail into slots, where the shell first expands the wildcard into the full pile of envelopes (filenames), then hands each one to echo one at a time, so if there are no .txt files the loop just gets a literal "*.txt" string unless nullglob is set.

0
Devraj B.Devraj B.Jun 13, 2026

The "in" after the variable locks this to for, answer is A.

1
Yusuf A.Yusuf A.Jun 14, 2026

The "in" keyword is definitely the tell, though it helps to also remember that "of" goes with for...of so you have a quick mental pair to anchor both loop types at once.

0
Mateus R.Mateus R.Jun 3, 2026

Think of it like a vending machine that keeps cycling until it runs out of snacks, and that is exactly what "until" does here, it keeps looping through each .txt file until the list is exhausted, which fits the pattern of iterating over a group of items perfectly. I am going with C on this one, the syntax lines up and the logic makes sense when you picture that vending machine working through its inventory one item at a time.

-1
Yusuf A.Yusuf A.Jun 6, 2026

Hey Mateus, I get the vending machine picture but "until" actually checks a condition and keeps looping while that condition is false, so it is not really built for walking through a list of items one by one the way "for" is, and a senior on my team drilled into me that "for file in *.txt" is the classic pattern when you just need to touch each file in a set.

0
Full 117-102 Practice