Bird
0
0

Given a CSV file data.csv with content:

medium📝 Command Output Q4 of 15
Bash Scripting - File Operations in Scripts
Given a CSV file data.csv with content:
name,age,city
John,22,Boston
Jane,30,Seattle

What is the output of this command?
awk -F',' '$2 > 25 {print $1}' data.csv
ANo output
BJane
CJohn Jane
DJohn
Step-by-Step Solution
Solution:
  1. Step 1: Understand awk filter condition

    $2 > 25 means print lines where second column (age) is greater than 25.
  2. Step 2: Check data rows

    John's age is 22 (not > 25), Jane's age is 30 (greater than 25), so only Jane matches.
  3. Final Answer:

    Jane -> Option B
  4. Quick Check:

    awk filters rows by condition correctly [OK]
Quick Trick: Use awk '$column > value' to filter numeric CSV fields [OK]
Common Mistakes:
MISTAKES
  • Assuming string comparison instead of numeric
  • Printing wrong column
  • Ignoring header line effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes