Linux fundamentals
Shell CSV Processing Coding Interview Problem
Written and reviewed by Sahil Srivastav
What this interview round tests
Shell CSV processing interviews show up in backend, data platform, SRE, and DevOps screens because engineers are often asked to turn a plain file into a trustworthy summary from the terminal. The prompt may sound like "awk group by sum" or "process csv in bash," but the grading usually cares about headers, numeric totals, stable ordering, and exact stdout.
This challenge gives you a real shell repository with a failing test suite. You aggregate sales CSV data by region, sum integer amounts, and return deterministic tab-separated output without reaching for pandas, a database, or a hand-waved one-liner.
The scenario
You are handed a sales export from an operations workflow. Each row records a region, product, and amount, and a downstream report needs one line per region with the total amount collected for that region.
The starter script is intentionally incomplete. It can read or echo rows, but it does not produce the grouped totals the tests expect. Your job is to make the shell script skip the header, aggregate the right fields, and sort the final report predictably without changing the fixtures or tests.
What you’ll practice
- Reading simple CSV input with standard Linux text-processing tools
- Skipping header rows so column names never become data
- Grouping by a field and summing numeric amounts with awk-style aggregation
- Formatting tab-separated report rows that downstream tools can compare reliably
- Sorting totals descending with deterministic tie-breaking by region
- Keeping a bash data-processing solution compact, reproducible, and testable
How to approach it
Start from the failing tests and the fixture CSV. Identify the contract before writing the pipeline: which column is the group key, which column is numeric, what delimiter the output uses, and how the final rows must be ordered.
Avoid relying on input order or associative-array traversal order. A robust interview answer separates aggregation from presentation: compute the per-region totals in one pass, format normalized rows, and apply explicit sorting so repeated runs produce the same report every time.
The starter repository ships with a failing test suite and a bundled verify.sh. Reviewed reference solutions are part of Gronex Pro — this page stays spoiler-free on purpose.
FAQ
Is this an awk group by sum interview problem?
Yes. It focuses on the practical version of that prompt: read a CSV, group rows by a column, sum an amount column, and emit a stable sorted report. You work in a repo with executable shell tests instead of only describing the command aloud.
Can I process CSV in bash without pandas for this challenge?
Yes. The fixture is intentionally simple enough for core shell tools, so the work is about careful field handling, numeric aggregation, and deterministic output. In a broader production setting, quoted fields and embedded commas would be a reason to reach for a real CSV parser.
Does this page reveal the exact shell solution?
No. The public page explains the interview shape and the skills involved. The starter repository contains the failing contract, and Gronex Pro includes the reviewed solution after you work through the challenge.