這些做工精細,做他們應該(打印文件foo的內容):的bash/zsh中輸入進程替換給出與結合語法錯誤而
cat <foo
while read line; do echo $line; done <foo
cat <(cat foo)
但是這給了我在zsh的語法錯誤:
zsh$ while read line; do echo $line; done <(cat foo)
zsh: parse error near `<(cat foo)'
和bash:
bash$ while read line; do echo $line; done <(cat foo)
bash: syntax error near unexpected token `<(cat foo)'
有誰知道原因,也許一個解決方法嗎?
注:這顯然是一個玩具的例子。在實際的代碼,我需要while循環體在主shell進程執行,因此,我不能只用
cat foo | while read line; do echo $line; done
是的,確切地說。我在你的帖子前一分鐘就知道了,並回答了我自己:)但我會刪除我的答案並接受你的答案。謝謝! –
太棒了!因此'貓<(貓富)'也行! – olibre