I'm trying to write a bash script that is jumping into each subfolder and then jumps back to main folder (and so on...). The difficulty are the path names that have spaces.
for path in "`find -type d | tr -d './'`"
do
echo "Next Pathname: $path"
cd $path
echo "I'm in path $pathr"
cd ..
done
The Error Message is "filename or path not found". When I change
cd $path
to
"cd $path"
then I get the error message "filename too long".
Could you help me? - I don't know how to separate this string (or write something more convenient).
The problem is that
find
can only output a stream of bytes, so you have to be careful to make it output something you can split in a lossless way. The only character not allowed in a file path is ASCII NUL, so let's use that:It handles all kinds of filenames: