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.
More on awk, sed, grep and jq one-liners
Print only the lines containing "ERROR" with 3 lines of context, and show line numbers.BeginnerSum the response sizes (field 10) in an Nginx access log and print the total in MB.BeginnerReplace `DEBUG` with `INFO` in a config file in place, keeping a backup.BeginnerExtract all unique email addresses from a file.BeginnerFrom `kubectl get pods -A -o json`, list pods that are not Running, as namespace/name/phase.IntermediatePrint the 3rd column of a CSV whose fields are separated by commas, skipping the header.Beginner