Pattern

I have a deadline and need to come up with a script that does the following.
Goes through the file below and prints only the lines that show a count of zero (0) in column 2.
Here is the file

Type    Count
Albert    25553
Albert    0
Albert    25555
Comb    0
Comb    25557
Comb    12436
Frank    25559
Frank    52340
Frank    0
Jones    0
Jones    25563
Jones    8964
Karl    0
Karl    0
Karl    202
Fine    25568
Fine    3561
Fine    25570

Here is my little script.

cat filename | grep -v "0"

I am not sure why it does not work.

If you want to only display the lines whose second colums is 0 then :

awk '$2==0' yourfile

If you also need the header line:

awk 'NR<2||$2==0' yourfile

---------- Post updated at 05:45 PM ---------- Previous update was at 05:41 PM ----------

It will not work because anyline that contains a '0' in any columns, would be filtered out.

So lines like :

Hello 0
Hello 1230456
0123 Hello
Hell0 1234

Would also be filtered out... which will not fit your needs

So if you want select lines whose second field is not null

awk '$2!=0' yourfile

or

awk '$2' yourfile

A very simple example assuming the zero is at the end of the line and eliminating useless use of cat:

 
grep " 0$" filename