如何在同一进程中使 bash 找到 运行?
How to make a bash find run in same process?
先写代码
echo $$ - $BASHPID
find . | while read -r file; do
echo $$ - $BASHPID: ${file}
done
问题是 while
中的代码在子进程中 运行ning。我怎样才能在同一个过程中制作这个 运行?
只需使用process substitution:
echo "$$ - $BASHPID"
while read -r file; do
echo "$$ - $BASHPID: ${file}" #better to quote!
done < <(find .)
# -----^^^^^^^^^
从给定的link:
Process substitution is a form of redirection where the input or
output of a process (some sequence of commands) appear as a temporary
file.
先写代码
echo $$ - $BASHPID
find . | while read -r file; do
echo $$ - $BASHPID: ${file}
done
问题是 while
中的代码在子进程中 运行ning。我怎样才能在同一个过程中制作这个 运行?
只需使用process substitution:
echo "$$ - $BASHPID"
while read -r file; do
echo "$$ - $BASHPID: ${file}" #better to quote!
done < <(find .)
# -----^^^^^^^^^
从给定的link:
Process substitution is a form of redirection where the input or output of a process (some sequence of commands) appear as a temporary file.