I was wondering how to filter a table with several columns based on a specific value in each of the columns of interest.
I have this example here:
Chr1 16644 0 0 1 1
Chr1 16645 0 0 1 1
Chr1 16646 0 0 1 1
Chr1 16647 0 0 1 1
Chr1 16648 0 0 1 1
Chr1 16649 0 0 1 1
Chr1 16650 0 0 1 1
Chr1 16651 0 0 1 1
Chr1 16782 0 0 0 0
Chr1 16783 0 0 0 0
Chr1 16784 0 0 0 0
Chr1 16785 0 0 0 0
Chr1 16786 0 0 1 1
Chr1 16787 0 0 1 1
Chr1 16788 0 0 1 1
Chr1 16789 0 0 1 1
Chr1 16790 0 0 1 1
And I would like to remove all the rows containing a zero in all of the columns 3,4,5,6.
I have tried it as such
cat STARsamples_read_depth.txt | awk '$3 != 0 && $4 != 0&& $5 != 0 && $6 != 0' | less
But it removes also the rows where only some of these columns have a zero, not in all four!
Is there a way to do it?
thanks
Assa
Asked by Assa Yeroslaviz
(207 rep)
Oct 18, 2023, 08:31 AM
Last activity: Oct 18, 2023, 03:18 PM
Last activity: Oct 18, 2023, 03:18 PM