↑ ↓ select, Enter open, Esc close

Filter CSV rows by the value in a column

Adjust the values, the command updates live
user@server
awk -F';' -v c=3 -v w='active' 'NR == 1 || $c == w' export.csv

Splits each line at the given character and prints it if the column exactly matches the value. The first line is always printed so the column headings are kept. For Excel exports created with a German locale, the semicolon is the usual delimiter.

Note: This is a simple split at the delimiter: quoted fields that contain the delimiter themselves are split incorrectly. If the values are quoted, the quotes must also be part of the value searched for.

Also searched as

  • filter csv file command line
  • awk filter csv by column value
  • extract rows with specific value from csv

Related one-liners

All in Text processing

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.