我需要一种方法来杀死当前目录中运行的所有内容.我对shell很新,所以原谅我是愚蠢的,或者可能不理解你的答案.我有一个不太合适的把握,但是如果你愿意花些额外的时间来解释你的问题解决方案到底是什么,我将不胜感激.
解决方法:
你必须使用lsof命令然后参数将是你要杀死进程的目录
#!/usr/bin/env bash
lsof $(pwd) | \
awk -F " " ' { print $2 } ' | \
while read process ; do
[[ ${process} == "PID" ]] && continue;
# kill the processes here
# if you assign each process to a variable or an array
# you will not be able to access it after leaving this while loop
# pipes are executed as subshells
echo ${process};
done
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。