How can I do a 'where' clause in Linux shell? How can I do a 'where' clause in Linux shell? bash bash

How can I do a 'where' clause in Linux shell?


An AWK program is a series of pattern action pairs, written as:

condition { action }

The condition part is your filter.

For example, to get all lines(19th column has at least 2 chars):

$ awk -F, 'length($19)>1' file.txt

When {action} part is missing, the default action is to print the record.


This should work:

awk -F ',' '{if (length($19) < 2) { print $0 }}' file.txt

It prints the whole line if the length of the 19th field is smaller than 2.