Small inventory exports often share an ID but keep different fields in separate files. awk can load a key-to-owner file into an associative array and append the matching owner to rows from the main export without opening a database or spreadsheet.
The example uses simple comma-delimited files where the first field is the key. The lookup file has no header, the main file has a header, and rows with keys missing from the lookup file are omitted so unmatched records do not look assigned.
Use this pattern for plain delimited text such as host inventories, username maps, or small reports. If the data is quoted CSV with embedded commas or newlines, use a CSV-aware tool before relying on awk -F, because field splitting by comma alone cannot parse quoted records.
Related: How to filter rows by a column with awk
Related: How to print selected columns with awk
Related: How to convert delimiters with awk
web-01,apps-team db-01,data-team cache-01,platform-team
The lookup file is intentionally headerless so every row can be loaded into the owner array without a header-skip condition.
host_id,env,role web-01,prod,nginx db-01,prod,postgres batch-01,staging,worker
The batch-01 row has no matching key in owners.csv, which makes the join behavior visible in the final output.
$ awk -F, 'BEGIN { OFS=FS } NR==FNR { owner[$1]=$2; next } FNR==1 { print $0, "owner"; next } $1 in owner { print $0, owner[$1] }' owners.csv hosts.csv
host_id,env,role,owner
web-01,prod,nginx,apps-team
db-01,prod,postgres,data-team
NR==FNR is true only while awk is reading the first file, so those rows build the owner lookup array. After next skips the rest of the rule set for the first file, the second file is printed only when its key exists in that array.
Keep the lookup file before the main file on the command line. Reversing the file order builds the array from the wrong data and changes the join result.