Filtered command output can look correct while still matching text from the wrong field, especially when a status, owner, or region value appears in more than one column. Use awk when the condition belongs to a numbered column instead of anywhere on the line.
awk splits each input record into fields according to -F. In a simple comma-delimited file, $1 is the first column, $2 is the second, and a rule such as $2 == “failed” prints only rows whose second field is exactly failed.
The sample steps use a small CSV-style fixture without quoted commas. For CSV exports that contain embedded commas, escaped quotes, or multiline fields, use a CSV-aware parser before passing rows to awk or choose a delimiter that cannot appear inside the data.
Related: How to print selected columns with awk
Related: How to count rows by field with awk
$ cat > orders.csv <<'EOF' order_id,status,region,total 1001,open,west,42 1002,failed,east,125 1003,closed,west,78 1004,failed,west,64 EOF
$ awk -F ',' 'NR == 1 || $2 == "failed" { print }' orders.csv
order_id,status,region,total
1002,failed,east,125
1004,failed,west,64
NR == 1 keeps the header row. $2 == “failed” is a case-sensitive exact string comparison against the second field.
$ awk -F ',' '$2 == "failed" { print }' orders.csv
1002,failed,east,125
1004,failed,west,64
Use $3 == “west” to match the region column in the sample file, or change -F ',' when the data uses a different delimiter.
$ rm orders.csv