shell script progs help

I'am new to unix i'am in dilemma whether my progs r correct or not.

Q1)print all the lines in the file which have occured twice and store them in a seperate file called two.dat. the lines which have occured once in a seperate file called one.dat.also print the number of words which have occured twice?

Q2)print all the lines in file f1 which contain the patterns "john", "jim","paul" and also print the number of words in those lines?

Please read our rules and note:
(6) Do not post classroom or homework problems.