简单的问题,我运行这个命令
ss -tulpnoea|grep -i water|grep -v 127
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
.....
我试过 2> /dev/null ...
ss -tulpnoea|grep -i water|grep -v 127 2> /dev/null
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
.....
如何避免有关 cgroup2 mount 的烦人消息?发行版是 Slackware 15.0
您在管道中的错误位置进行了重定向。据推测错误来自
ss
命令,因此您应该在此处隐藏错误输出。或者您可以将命令的输出和重定向作为一个整体进行分组。以下是抑制任何错误的一些可能的解决方案:
重定向生成消息的命令的标准错误:
在子 shell 中运行命令并重定向子 shell 的标准错误:
将命令分组并重定向该组的标准错误:
或者,如果您特别想抑制该错误而不是其他错误(受 shell 支持)