Bird
0
0

What is the output of this command on a file with lines:

medium📝 Command Output Q13 of 15
Linux CLI - Text Processing
What is the output of this command on a file with lines:
1: apple 10
2: banana 20
3: cherry 30

awk '$2 > 15 {print $1}' file.txt?
Aapple
Bbanana cherry
C10 20 30
Dapple banana cherry
Step-by-Step Solution
Solution:
  1. Step 1: Understand the pattern condition

    The pattern '$2 > 15' means only lines where the second field is greater than 15 are selected.
  2. Step 2: Apply the condition to each line

    Line 1: 10 > 15? No. Line 2: 20 > 15? Yes. Line 3: 30 > 15? Yes.
  3. Step 3: Print the first field of matching lines

    For lines 2 and 3, print $1: 'banana' and 'cherry'.
  4. Final Answer:

    banana cherry -> Option B
  5. Quick Check:

    Fields > 15 print first field = banana, cherry [OK]
Quick Trick: Check pattern filters before printing fields [OK]
Common Mistakes:
  • Printing all lines ignoring pattern
  • Printing second field instead of first
  • Confusing numeric comparison with string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes