Count pattern line by line

I have a file like below with more than 30,000 lines:

Someword "mypattern blah blah mypattern blah  mypattern  blah "
Someotherword "mypattern blah blah mypattern blah  mypattern  blah"
Someword  "mypattern blah blah blah  mypattern  blah "
Someword "mypattern blah blah mypattern blah  mypattern  mypattern  blah "
Someword "mypattern blah blah mypattern blah  mypattern  blah "

The second column is within quotes and it contains my pattern - "mypattern" which i need to count line by line

I am trying to get a output like this :

Someword 3
Someotherword 3
Someword  2
Someword 4
Someword 3

Hello ctrld,

I have a few to questions pose in response first:-

  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.

As a first thought, you might get somewhere with sort and uniq commands, but I'm not quite sure what you want. If you have a go at coding yourself, it might become clearer to us.

Kind regards,
Robin

To make the situation clear, this thread is closed till the OP replies to the questions of the moderator