Needless to say, many soldiers turned and ran during the various attacks and counterattacks in Stephen Crane's Civil War novel, The Red Badge of Courage. Both of the main characters, Henry and Wilson, joined in the flight when the action got too hot. I assume you are probably referring to the soldier who is restrained during the first Confederate attack in Chapter V.
The lieutenant of the youth's company had encountered a soldier who had fled screaming at the first volley of his comrades. Behind the lines these two were acting a little isolated scene. The man was blubbering and staring with sheeplike eyes at the lieutenant, who had seized him by the collar and was pommeling him. He drove him back into the ranks with many blows. The soldier went mechanically, dully, with his animal-like eyes upon the officer. Perhaps there was to him a divinity expressed in the voice of the other—stern, hard, with no reflection of fear in it. He tried to reload his gun, but his shaking hands prevented. The lieutenant was obliged to assist him.
Running, or "skedaddling," during battle was fairly common during many Civil War battles. Most of the time, the men ran to the rear of the action and eventually reformed to fight again. Many times it was an act of self-defense rather than simply fear; soldiers could often see when a situation had become untenable, and their movement was regarded as an act of self-preservation. Soldiers who deserted under fire, completely leaving their units and the battlefield, were often dealt with harshly. Floggings were a common punishment; execution was rare.