Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在制作一个运行进程的shell脚本,我正在搜索这样的进程ps -ea | grep <search_term>,我可以找到该进程很好,但我想将该进程的pid设置为我的shell脚本中的一个变量,然后等到那个过程结束。这是我想要的类型:
ps -ea | grep <search_term>
PID= (returned and parsed value of "ps -ea | grep <search_term>") echo $PID wait $PID
PID=$(ps -ea | awk '/<search_term>/,NF=1')
在 Linux 上获取进程 ID 的 Shell 脚本