This often spills into works that depict normal life in the military, more often than not, a higher ranking officer or NCO will randomly scream at the low private and punish him with push-ups or a random exercise. Recruits often enter with at least a passing familiarity with the trope and don't take it (or the instructor) seriously. In something of an ironic twist, the popularity of this character has impacted real military training.
If a British work has Shown Their Work, this role may well be filled by the Provost Sergeant, who is in charge of base discipline, and who the drill sergeants send recruits to go and see for their punishment.
In Britain, the popular image is of the Sergeant Major, who is usually much less abusive, but no less demanding, and may or may not be marching up and down the square.