若要遍历的文件名带空格,则不能直接用 $(ls) 来做进程替换,而应该用通配符由 shell 进行扩展。
即应该是:
for f in *.md do echo $f done
而不是
for f in $(ls *.md) do echo $f done