I think you'll find that the teams don't walk out on the field to shake hands at the beginning of the game. The two captains and the umpires come out first and a coin is tossed to see who gets to choose who bats or bowls first. Then the 11 players on the bowling/fielding side come out, and two players of the batting side. As each batsman is got out another comes on to replace him until (usually) the first 10 batsman are got out - leaving one batsman who has not been got out. Then the two batsmen go off the field to change out of their pads etc, and the rest of the previously batting side comes on to bowl/field while two of the previously bowling/fielding side come on to bat.
The big shaking hands routine occurs at the end of the match, not the beginning.