Shaw's 2-yard run with 8:05 left in the game gave the Gamecocks a 35-21 lead and South Carolina (4-1, 2-1 SEC) held on for a third straight victory.
Shaw completed 17-for-20 for 262 yards and added 50 rushing yards on nine carries.
Mike Davis led the Gamecocks' ground game with 106 yards and two scores on 21 tries.
The Wildcats (1-4, 0-2) fell for a second consecutive game as Jalen Whitlow was limited to 178 passing yards and two TDs on 17-for-24 efficiency.
He also picked up 69 rushing yards with a touchdown on 17 carries.