gpt4 book ai didi

linux - 查找某个目录下所有正在运行的脚本

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:54:49 25 4
gpt4 key购买 nike

我在'abc' 目录下有一堆shell 脚本(其中一些嵌套很深)。它下面可能有 100 个 shell 脚本。我想找到当前正在运行的 shell 脚本。

我可以使用以下命令获取脚本列表

find abc -name "*.sh" | awk -F/ '{print $NF}'

当我想知道某个脚本是否正在运行时,我会使用

ps aux | grep "[t]emp.sh"

我不确定如何在不编写 shell 脚本的情况下组合上述 2 个命令来实现我想要的。

最佳答案

使用 process substitution (bash) :

grep -f <(find . -name "*.sh" -printf "%f\n") <(ps aux)

关于linux - 查找某个目录下所有正在运行的脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27112596/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com