gpt4 book ai didi

bash - 如何使 bash 查找在同一进程中运行?

转载 作者:行者123 更新时间:2023-11-29 09:35:12 24 4
gpt4 key购买 nike

代码优先

echo $$ - $BASHPID

find . | while read -r file; do
echo $$ - $BASHPID: ${file}
done

问题是 while 中的代码在子进程中运行。我怎样才能让它在同一个进程中运行?

最佳答案

只需使用 process substitution :

echo "$$ - $BASHPID"

while read -r file; do
echo "$$ - $BASHPID: ${file}" #better to quote!
done < <(find .)
# -----^^^^^^^^^

来自给定的链接:

Process substitution is a form of redirection where the input or output of a process (some sequence of commands) appear as a temporary file.

关于bash - 如何使 bash 查找在同一进程中运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30870059/

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