I have a tab delimited file with n rows and m columns, I want to print the first three column and search for a pattern and print that column if present. I tried to search and print in sed but unable to do it to print first 3 column and then search for the pattern.
example I have file like
col1 col2 col3 col4 col5 col6
test 23 2323 32 635 36354
test2 354 35b 345 345 555
test4 486 g4 435 0.43 34
test5 0.6 35 0.34 0.234 34563
output I want is (if pattern I search is 'col6' for example)
col1 col2 col3 col6
test 23 2323 36354
test2 354 35b 555
test4 486 g4 34
test5 0.6 35 34563