有很多方法可以在 bash 的 while 循环中使用数据。
其中之一是
some_proc | while read line
do
something
done
另一个是
while read line
do
something
done < <(some_proc)
问题 1:我什么时候应该更喜欢其中一个。
问题 2:如果我不是从进程中读取some_proc
而是redirection
直接在文件上使用,那么该文件何时打开和关闭。