【发布时间】:2020-03-31 05:00:17
【问题描述】:
ps aux | grep node | grep -v grep | awk '{print $2}' | xargs kill -9
我使用上述命令杀死所有 Node.js 进程(Ubuntu),但如果没有节点进程正在运行,它将显示错误(stderr)。是否可以在管道中使用 if 语句来避免 xargs 收到任何内容?
类似:
ps aux | grep node | grep -v grep | awk '{print $2}' | if [ $pip ] ; then
xargs kill -9 $pip
fi
【问题讨论】:
标签: bash shell ubuntu pipe pipeline