Originally Posted by ProAm500
Thanks guys. I tried pretty much all your guys solutions and different variations of them and for most them I kept getting the same answer in some form
I believe the answer should be something like or at least in some form......
Smith, Joe SR CIS
Clark, Sue SR CIS
Brown, Steve JR CIS
Duck, Donald SR CIS
Simon, Sam JR CIS
My instructor handed it back and told me to give it another shot. Her hint was "so start with sorting the files, you need two grep commands to pull in only CIS and JR, you should only count the records once (the unique command) and the use the cut command to list only the names". I'm going to keep playing around with it and see what I get.
The answer you report getting using the solutions offered here is in accordance with the OP requirement ""Print just the names of the Junior CIS majors that are enrolled in both A and B". AIUI "just the names" means it is wrong to print JR and CIS (which is anyway redundant information because those are the properties that have to be matched).
Your instructor's hinted technique of using two greps, a uniq and a cut would work but is less elegant than the single grep -f ClassA ClassB
followed by something to prune "JR CIS" such as cut, awk or sed.