Shaw enlisted in the Union Army for the American Civil War, joining Company A, 35th New York Volunteer Infantry Regiment as a private in June 1861. He was later promoted to corporal, and he served until being mustered out with the rest of his regiment in June 1863. Shaw took part in the regiment's activities in Virginia and Maryland, including; construction of Fort Tillinghast and Fort Craig (autumn 1861); guard and patrol duty in and around Falls Church, Virginia (winter 1861-1862); guard and patrol duty in and around Falmouth, Virginia (spring 1862); battles at Rappahannock Station, White Sulphur Springs, and Gainesville (summer 1862); Second Battle of Bull Run (August 1862); Chantilly (September 1862); South Mountain (September 1862); Antietam (September 1862); and Fredericksburg (December 1862). In January, 1863, the regiment was assigned to the provost guard brigade in Falmouth, and also performed guard and patrol duty along the Aquia Creek railroad. In May, the regiment left Maryland for New York so it could be mustered out.