【问题标题】:pipe to kill command管道杀死命令
【发布时间】:2017-03-05 10:39:32
【问题描述】:

我正在终端尝试这个:

/tmp ps x | grep -m1 firefox | cut -d' ' -f1 | kill -KILL    
kill: not enough arguments

如何通过管道将 pid 杀死?

我试过了,没用

 /tmp ps x | grep -m1 firefox | kill -KILL $(cut -d' ' -f1)
cut: -: Input/output error
kill: not enough arguments

【问题讨论】:

    标签: unix kill


    【解决方案1】:

    您可以使用 xargs。这会读取 command1 的输出并将其用作运行 command2 的参数:

    command1 | xargs command2
    

    你的情况

    ps x | grep -m1 firefox | cut -d' ' -f1 | xargs kill -KILL 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-22
      • 1970-01-01
      • 2023-03-24
      • 2020-11-30
      • 2019-02-04
      • 1970-01-01
      • 2023-04-04
      相关资源
      最近更新 更多