当递归循环遍历包含空格的文件的文件夹时,我使用的 shell 脚本是这种形式,从internet http://mywiki.wooledge.org/BashFAQ/020:
while IFS= read -r -d $'\0' file; do
dosomethingwith "$file" # do something with each file
done < <(find /bar -name *foo* -print0)
我想我理解 IFS 位,但我不明白 '< <(...)
' 字符的意思。显然这里有某种管道正在运行。
你看,很难用谷歌搜索“
<()
叫做过程替代 http://www.gnu.org/software/bash/manual/html_node/Process-Substitution.html#Process-Substitution在手册中,它类似于管道,但传递以下形式的参数/dev/fd/63
而不是使用标准输入。
<
从命令行上命名的文件读取输入。
Together,这两个运算符的功能与管道完全相同,因此可以将其重写为
find /bar -name *foo* -print0 | while read line; do
...
done
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)