Bird
0
0

What will be the output of this command on a CSV file items.csv with content:

medium📝 Command Output Q5 of 15
Bash Scripting - File Operations in Scripts
What will be the output of this command on a CSV file items.csv with content:
id,price
1,10
2,20
3,15

awk -F',' 'NR>1 && $2 >= 15 {print $1}' items.csv
A1
B1 2 3
C2 3
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Understand NR>1 skips header

    NR>1 means awk ignores the first line (header).
  2. Step 2: Filter rows where price >= 15

    Rows with price 20 and 15 match, so print their ids: 2 and 3.
  3. Final Answer:

    2 3 -> Option C
  4. Quick Check:

    NR>1 skips header; $2 >= 15 filters rows [OK]
Quick Trick: Use NR>1 in awk to skip CSV header line [OK]
Common Mistakes:
MISTAKES
  • Including header in output
  • Using wrong comparison operator
  • Printing wrong column

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes