Im trying to iteratively compose a directory exclusion list for Find. I construct the exclusion path through iterating through a text file. This is all working however Ive come across a stumbling block when it comes to paths with spaces in them. If I pass a path in with spaces Find doesn't recognise them. Despite the path being within speech marks
This demonstrates:
####
line="Documents/Microsoft User Data"
excludehead="-not ( -path "
excludetail=" -prune )"
excludefolder="$HOME/$line"
###
base_list=$(printf %s "$excludehead" "\"$excludefolder\"" "$excludetail" )
find $HOME $base_list -name "*[<>:/|?#%\\\\*]*"
This results in:
find: User": unknown primary or operator