Particularly in contrast to when battles were fought in closer proximity before the modernization of warfare. Did soldiers ever know names of opposed combatants, or had war become an anonymous affair by then? In particular I have historical epics like The Iliad in mind where soldiers appear to have fair knowledge of opponents and familial histories.
In particular I have historical epics like The Iliad in mind where soldiers appear to have fair knowledge of opponents and familial histories.
This is a problematic mindset to have. We can not conflate fiction with reality. The fact of the matter is, war has always been pretty impersonal. For thousands of years formation warfare dominated Europe and further, mercenary armies were also incredibly popular for basically the entirety of late ancient / medieval / modern history. I don't want to take these claims too far because it's a bit out of my wheelhouse but the general idea nonetheless holds true -- warfare was not really a thing where two people would honorably duel each other or know the name of their designated opponent or the family the person they were fighting hailed from for quite a while before WW1.
Anyways, the answer is yes it was an anonymous affair by then. The Napoleonic Wars brought upon the first case of mass mobilization where hundreds of thousands of men would be raised up to go fight on all sides, and this was in the late 18th century - early 19th century. By the time WWI came around conscription armies were part of the norm for European armies. For the Schlieffen Plan, Germany was planned to mobilize 2.07 million men with approx 21,000 trains within the first twenty days. In 312 hours from mobilization, roughly 11,000 trains would shuttle 119,754 officers, 2.1 million conscripted men, and six hundred thousand horses to various marshaling areas under Stage Seven of the Military Travel Plan. Even more spectacularly, the 1.6 million men -- 950 battalions -- of the Western Army rolled across the Rhine River at the rate of 560 trains, 54 cars each, per day.
You're thinking now, "So what?" Well, the "So what?" is that look at all those numbers! This is not an era of small armies of local tribes or city-states waging war against each other. This is millions upon millions of men being shuttled onto a train, put on a front hundreds if not thousands of miles away, and then fighting a war against another mass of conscripted men who also traveled hundreds if not thousands of miles on a train and put into somewhat arbitrary battalions and divisions. There is absolutely no way, from a sheer numerical standpoint, one man on one line could have known the average man on the other line in the other trench.
I like to quote a letter from an anonymous Belgian soldier at the Siege of Liège, where the Germans assaulted a ring of highly defended forts in Belgium:
*As line after line of German infantry advanced, we simply mowed them down. ... They made no attempt at deploying, but came on, line after line, almost shoulder to shoulder, until, as we shot them down, the fallen were heaped one on top of the other, in an awful barricade of dead and wounded men that threatend to mask our guns and cause us trouble.*^[1]
War was, especially in the early stages of the war, pure chaos and not this pretty picture of war you are imagining. While German divisions would be broken up into Bavarians, Wurttermbergers, Prussians, Pommerians, Saxons, etc. it's not like the French knew this. The Germans had a standard military dress and it's not like they would telegram the other side saying "Yeah, the Bavarians are coming this day", y'know?
So my answer would be a resounding yes, it was entirely anonymous at this stage. The most the average French soldier would know was that they were Germans and the Germans that the enemy was French. At the very best the higher officers would know that the enemy were Bavarians or Saxons or Prussians or the opposing commanding officer. However the average WWI man, French or German, who were on the field or in the trenches and actually getting shelled and were unleashing mass fire on the grey or blue blob that approached them did not know the ethnic identities let alone the names of the tens of thousands of men that they were killing sometimes 100-200m away.
[1] Cited in Source Records of the Great War, ed. Charles F. Horne (USA: National Alumni, 1923), 2:49