【发布时间】:2015-09-06 03:19:46
【问题描述】:
Shellcheck doesn't like 我的 for 在 Bash 中循环 find。
for f in $(find $src -maxdepth 1 -name '*.md'); do wc -w < "$f" >> $path/tmp.txt; done
它建议:
1 while IFS= read -r -d '' file
2 do
3 let count++
4 echo "Playing file no. $count"
5 play "$file"
6 done < <(find mydir -mtime -7 -name '*.mp3' -print0)
7 echo "Played $count files"
大部分我都明白了,但有些东西还不清楚。
第一行:什么是'' file?
第六行:< < (find). 中的空白空间有什么作用?< 是否像往常一样重定向?如果是,重定向到do 块是什么意思?
有人可以帮忙分析一下吗?这是在目录中迭代某种文件的正确方法吗?
【问题讨论】:
标签: bash command-line terminal shellcheck