systemctl’s output isn’t sent to a terminal, e.g. if it’s piped to
grep, then it allows each column of its output to grow as much as necessary to fit the longest item in the list. This is what’s happening here: some unit in the list of units has a very long name, and aligning the output of all units produces the large space between
loaded failed failed.
To filter the unit output, use
systemctl’s built-in pattern matching:
sudo systemctl list-units '*yarn*'
You can limit the output to the lines you’d get with
grep with the
--no-legend option, avoid colouring and special characters with the
--plain option, and avoid starting a pager with the
sudo systemctl list-units --plain --no-legend --no-pager '*yarn*'
There are better sub-commands if you want to retrieve the status of specific units; see for example The "proper" way to test if a service is running in a script.