grep -P -c

Hi,

I have a file with lots of lines as follows.

-----------------

AAK40388.1_4 1.4.3.19
AAK40389.1_4 1.5.1.12
AAK40395.1_3 1.1.1.205
AAK40400.1_3 1.1.1.-
AAK40402.1_1 1.17.4.1
AAK40409.1_4 1.9.3.1
AAK40433.1_3 1.18.1.-
AAK40461.1_2 1.1.1.103
AAK40465.1_1 1.1.1.205
AAK40466.1_1 1.2.4.1
AAK40479.1_1 1.8.1.14

---------------

I used following code:

for i in {1..18}
do
     grep -P -c '_1 1\.$i\.' file >> g
done

But it returns all zero. I think the problem lies in '$', which represents an end character in Perl. As I do need a loop, so can you please tell me how to solve it?

Thanks a lot!
Dawn

Variables do not expand in single quotes. Try double quotes.

I'm still not sure whether your program will function properly however, because you haven't explained your intention or purpose here.

Thanks a lot for your answer. It works! I didn't differentiate between single and double quotes.