Interview Prep/Real-World Interview/awk, sed, grep and jq one-liners

Join two files on a common key column (like a SQL join) using shell tools.

AdvancedHands-onawk, sed, grep and jq one-liners
Answer
join -t, -1 1 -2 1 <(sort -t, -k1,1 users.csv) <(sort -t, -k1,1 orders.csv)
# awk version, no sorting required:
awk -F, 'NR==FNR {name[$1]=$2; next} ($1 in name) {print $0 "," name[$1]}' users.csv orders.csv

Key trick → NR==FNR is true only while awk reads the first file, so you load a lookup map first and then stream the second file against it.

All Real-World Interview questions Roadmap: Interview readiness

More on awk, sed, grep and jq one-liners