awk
1 / 13 · ≈ 9 min left
The problem
Support says some API calls take seconds and some orders look wrong. You have the access log and an export of the orders table, and no time to load them into a database. awk reads a file line by line, splits each line into fields $1, $2, $3 and so on, and runs a small program on each line.
The reps use two files. access.log has 4 lines with the fields IP, method, path, status and time in ms, separated by spaces: 10.0.0.12 GET /api/users 200 18, 10.0.0.7 POST /api/orders 201 95, 10.0.0.12 GET /api/orders 500 230, 10.0.0.9 GET /health 200 2. orders.csv has the header id,customer,country,amount and 5 rows: 1,ana,FR,30, 2,bob,DE,45, 3,chen,FR,25, 4,dina,US,60, 5,eve,DE,15. The answers work in any POSIX awk.