代码的格式足以让人流泪!
但是,这应该可以工作,假设在空格之前的目录名称中实际上没有反斜杠:
MainDir="/Users/redres/Dropbox/Computer Ebooks/Skimmed"
while IFS= read -d '' -r file
do
printf "File found: '%s'\n" "$file"
done < <(find "$MainDir" -print0)
例如:
$ mkdir -p 'Double Spaced Directory/Holograms/Object Lesson'
$ cp /dev/null 'Double Spaced Directory/Holograms/Object Lesson/Obstacle Course'
$ MainDir=$PWD/"Double Spaced Directory"
$ while IFS= read -d '' -r file
> do
> printf "File found: '%s'\n" "$file"
> done < <(find "$MainDir" -iname '*' -print0)
File found: '/Users/jleffler/soq/Double Spaced Directory'
File found: '/Users/jleffler/soq/Double Spaced Directory/Holograms'
File found: '/Users/jleffler/soq/Double Spaced Directory/Holograms/Object Lesson'
File found: '/Users/jleffler/soq/Double Spaced Directory/Holograms/Object Lesson/Obstacle Course'
$