Tuesday, July 26, 2022

[SOLVED] awk extract rows with N columns

Issue

I have a tsv file with different column number

1 123 123 a b c
1 123 b c
1 345 345 a b c

I would like to extract only rows with 6 columns

1 123 123 a b c
1 345 345 a b c

How I can do that in bash (awk, sed or something else) ?


Solution

Using Awk

$ awk -F'\t' 'NF==6' file
1 123 123 a b c
1 345 345 a b c


Answered By - xgadme
Answer Checked By - Terry (WPSolving Volunteer)