Example content of file.name:
Create variable sum, let i go from 1 to NF, and add 0 or 1 to sum depending on the awk ternary operator (?:). With $i to mark field content, add to sum 0 or 1, using sum += $i ? 1 : 0. In brief, if $i (i.e if $i!=0) use 1 for sum+=, if false (i.e. if $i=0) use 0 for sum+=.
In case sum=0, the only time this would happen is if every field is 0, thus remove those fields with if (sum!=0) print.
To filter out only those lines that have non 0 numbers repeated N times (for example 4) substitute 0 with 4 in if (sum!=0) print. This code will basically keep only those lines that contain at least one 0.
Modification of this code is easy, i.e. to keep lines that contain at least one number 3, change the condition in ternary operator (?:) to $i==3:
5. To filter out lines that contain ceratin number repeated N times
For example to keep only lines that contain 1 repeated 3 times:
6. To filter out lines that do not contain number repeated N times
For example to remove only lines that contain 1 repeated 3 times:
7. To count how many times certain number is repeated in each row
You can modify this code to count how many times in a row you have repeated 0, or any other number. To find out how many times 0 is in fields of each row:
You can modify this code to count how many times in a row you have repeated two or more numbers, for example 1 or 5. Change the code so that if $i is either 1 or 5 sum will be increased by 1.