on-internet
← Community

Filtering on a condition using the column names and not numbers

Stack Overflow ·

I am trying to filter a text file with columns based on two conditions. Due to the size of the file, I cannot use the column numbers (as there are thousands and are unnumbered) but need to use the column names. I have searched and tried to come up with multiple ways to do this but nothing is returned to the command line. Here are a few things I have tried: awk '($colname1==2 && $colname2==1) { count++ } END { print count }' file.txt to filter out the columns based on their conditions and head -1 file.txt | tr '\t' | cat -n | grep "COLNAME to try and return the possible column number related to

Comments

Sign in or sign up to comment and upvote.

No comments yet.