I am attempting to write a bash script that operates on each directory in a subset. Unfortunately the path contains spaces, and I am unable to change the name.
The for loop insists on breaking at each space; I have tried dozens of variants, but am unable to come up with a solution.
A simplified version is below.
#!/bin/bash
SOURCE="/Volumes/Time Machine Backups/Backups.backupdb/Zaphod"
for file in `ls -d "$SOURCE"/201*`
do
echo "File: $file"
done
Can anyone suggest how I can get every entry e.g. /Volumes/Time Machine Backups/Backups.backupdb/Zaphod/2017-06-30-215735 in a separate variable.