I am now developing a script to copy some files from directory A to multiple directories B following some directives , the script is working fine , but when it comes to files with spaces on them , he just considers them as multiple files , for example:
my_super_cool_file_2007039904_11 (3rd copy).pdf
when the file is in this loop:
for i in $(find $parent -mindepth 1 -maxdepth 1 -type f|cut -c 11-);do
echo "this is the file: $i"
done
it is considered as multiple files :
this is the file: my_super_cool_file_2007039904_11
this is the file: (3rd
this is the file: copy).pdf
i've tried replacing the space
with \space
using sed 's/ /\\ /g'
but it does not seem to solve my problem, for the loop it's 3 different files, i had also the same problem using ls
, and i need to stick to use find
find
correctly including to address your space problem and why your approach doesn't work. – Stéphane Chazelas Oct 04 '17 at 09:19