It gets complicated with layoffs, and companies don't operate the way they once did, because even though stock price was a big deal 'back in the day', these days due to the nature of the financial markets and the nature of income to certain percent of the population, 'shareholder management' is the king. Yes, in one way or the other most people have ties to stock, through individual holdings or through things like IRA's and 401k's, and even standard pensions are generally based around stock holdings. On the other hand a major change from the past is that executive compensation these days is roughly 90+% stock driven, cash payments to executives are a small part of their compensation, so they are even more aware of stock price, for obvious reasons. Likewise, while most people have exposure to stocks in one way or the other, there is a class of well off investor who make up most stock ownership, and a large percentage of their income is from investment income (and I am not going to put words like good or bad here, it is what it is, there are good aspects to this and not so good one).
Stock price isn't based the way people think, where if a company is profitable, they will be rewarded with a higher stock price, it doesn't work like that, and often stock prices work against what some would see as the common good. For example, laying off 10,000 employees is not great for the employees, their family or for the economy to a certain extent, for obvious reasons, but the stock analysts who are the ones responsible for how stock prices go, see that as a positive because they are cutting costs. Most people hear about hiring and think that is a good thing, people have jobs, etc, stock analysts hear that and worry about it and can downgrade a stock because of 'the cost' of hiring people. Companies return great results and get slammed, because stock analysts think they have too many workers, it happens. Yes, there is a tie between profits and stock price, but then look at companies like Amazon that lost money for years, Tesla that is still losing money but their stock is in the stratosphere (meanwhile the CEO of Ford got canned, despite having taken the company through the financial straits the car industry went through, and being profitable, because the stock price didn't soar, for whatever reasons).
UP likely did this because investors and management are not happy about the stock price, this is especially true if you have activist investors like hedge funds that are in business to give yields of 20% or more to their investors (who legally are very well off people, hence my original point, ordinary investors can't get into these). It is the world we live in, and cutting labor costs is a quick way to boost stock prices, to please analysts and do that, your price will go up, pure and simple. Without getting into an economic discussion, this isn't about capitalism per se, it is the type of it, and capitalism has changed over the years, once upon a time they actually taught in management school something called stakeholder management, and it was the way many companies were run, wasn't a panacea, greed existed, badly run companies existed, but there was some idea of how/where the company operated. These days it is very different, and most companies it is all about the stock price (if public). It is why some companies choose to stay private, one of the reasons Bose has refused to go public is because they don't want to be beholden to stock price and want to have the freedom to innovate, spend money on long term research, something public companies have a hard time with since stock analysts hate R and D or other costs like that.
Like I said, there are pluses and minuses, but the idea that stock prices or the Gordon Gecko line that stock price pressure makes companies more efficient is debatable, because what he was talking about often makes company cut muscle and bone and in the long run end up gutted, it all depends. I think the railroads are facing pressure, with energy prices in the gutter there isn't the demand for tanker traffic there was when Oil was soaring, pipelines also cut into traffic, and railroads have to face the future where coal is dying in favor of natural gas that is delivered via barge or pipeline mostly. I agree with another poster, usually they go after managers because they tend to be more expensive workers, so if you are gonna cut cost managers give you more bang for the buck, though it can backfire, but in quarterly world view of wall street they don't see that *shrug*. What form of capitalism is best I leave to others, but what you see with UP is more than likely a reflection of how capitalism works today.