Bird
0
0

Given a CSV file with columns: name,age,score, how to print names of people with score above 80 using awk?

hard📝 Application Q9 of 15
Linux CLI - Text Processing
Given a CSV file with columns: name,age,score, how to print names of people with score above 80 using awk?
Aawk -F',' '$2 > 80 {print $3}' file.csv
Bawk -F',' '$3 > 80 {print $1}' file.csv
Cawk -F',' '$3 < 80 {print $1}' file.csv
Dawk -F',' '{print $1}' file.csv
Step-by-Step Solution
Solution:
  1. Step 1: Set field separator to comma

    Use -F',' to split CSV fields correctly.
  2. Step 2: Filter rows with score > 80 and print name

    Score is third column ($3), name is first ($1), so condition '$3 > 80 {print $1}' works.
  3. Final Answer:

    awk -F',' '$3 > 80 {print $1}' file.csv -> Option B
  4. Quick Check:

    Filter by $3 > 80, print $1 = B [OK]
Quick Trick: Use -F',' for CSV and filter with condition in awk [OK]
Common Mistakes:
  • Mixing up field numbers
  • Not setting field separator
  • Printing wrong column

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes