Print lines where a specific column has a length condition

awkcsv

I am parsing a very large csv file, where the entry of column 26 has to be of length 10. I can see that there are cases where there are no entries (which is fine), but also cases where the entries have length less than 10 or greater than 10, that has to be erroneous. I am trying to print some of these lines to explore.

My attempt is:

awk 'length($26) < 10' my_file.csv | sort -u | cut -d ',' -f 26 | head

but this doesn't return the result I want – instead it returns a number of rows where the length of column 26 is in fact equal to 10. What am I doing wrong?

Best Answer

awk -F, 'length($26) != 10 { print }' /path/to/input > bad_field_length.txt
Related Question