代码优先
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/