Bird
0
0

Why does this command fail?

medium📝 Debug Q7 of 15
Bash Scripting - Text Processing in Scripts
Why does this command fail?
awk '{print $2}' file.txt -F ':'
ABecause print requires parentheses
BBecause -F ':' must be before the program, not after the file
CBecause file.txt does not exist
DBecause $2 is invalid without quotes
Step-by-Step Solution
Solution:
  1. Step 1: Analyze option placement

    The -F ':' option must come before the awk program and file name.
  2. Step 2: Correct command order

    Correct command: awk -F ':' '{print $2}' file.txt.
  3. Final Answer:

    Because -F ':' must be before the program, not after the file -> Option B
  4. Quick Check:

    Options before program and file [OK]
Quick Trick: Always put options before program and file [OK]
Common Mistakes:
MISTAKES
  • Placing options after file name
  • Misunderstanding $2 syntax
  • Assuming parentheses needed in print

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes