Bird
0
0

What is the purpose of using while read line in a bash script?

easy🧠 Conceptual Q1 of 15
Bash Scripting - File Operations in Scripts
What is the purpose of using while read line in a bash script?
ATo write lines to a file
BTo read a file line by line and process each line
CTo delete lines from a file
DTo count the number of words in a file
Step-by-Step Solution
Solution:
  1. Step 1: Understand the while read line construct

    This loop reads input line by line, storing each line in the variable line.
  2. Step 2: Recognize its use in file processing

    It is commonly used to process each line of a file or input stream sequentially.
  3. Final Answer:

    To read a file line by line and process each line -> Option B
  4. Quick Check:

    Reading lines = A [OK]
Quick Trick: Use while read to handle files line by line easily [OK]
Common Mistakes:
MISTAKES
  • Thinking it writes or deletes lines
  • Confusing with word count commands

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes