【问题标题】:Set the pid of a searched running process (ps -ea | grep <search>}) in shell在 shell 中设置搜索到的运行进程的 pid (ps -ea | grep <search>})
【发布时间】:2013-06-20 16:49:09
【问题描述】:

我正在制作一个运行进程的 shell 脚本,我正在搜索这样的进程 ps -ea | grep &lt;search_term&gt; 并且我可以找到该进程很好,但我想将该进程的 pid 设置为我的 shell 中的一个变量脚本,然后等到该过程完成。这是我想要的类型:

PID= (returned and parsed value of "ps -ea | grep <search_term>")
echo $PID
wait $PID

【问题讨论】:

    标签: shell ps


    【解决方案1】:
    PID=$(ps -ea | awk '/<search_term>/,NF=1')
    

    Shell script to get the process ID on Linux

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-07
      • 1970-01-01
      • 2011-12-28
      • 2023-03-23
      相关资源
      最近更新 更多