systemctl 输出被截断

systemctl 输出被截断

需要 grep 该命令的输出:

systemctl | grep failed

问题是它没有显示完整的单位:

systemd-...-clean.service loaded failed failed        Cleanup of Temporary Directories
systemd-...-setup.service loaded failed failed        Recreate Volatile Files and Directories
tcsd.service              loaded failed failed        LSB: Init script for TCSD
cups.socket               loaded failed failed        CUPS Printing Service Sockets

您可以看到单位显示如下:systemd-...es-clean.timer forsystemd-tmpfiles-clean.service

我尝试使用一个文件:

systemctl --failed > file

或者猫:

systemctl --failed | cat

但问题是一样的。我需要了解为什么会发生这种情况以及如何解决它。

答案1

这与管道无关,是systemctl的行为。使用--full开关获取全名:

--full
    Do not ellipsize unit names and truncate unit descriptions in the
    output of list-units and list-jobs.

答案2

首先将其传输到 less 然后尝试 grep: #systemctl status -l httpd | less | grep failed

相关内容