I have to work with path contain space character in Linux, My command below are works fine for non-space path, but it will fail if path contain space.
#!/bin/bash
for i in $( find "." -maxdepth 1 -mindepth 1 -type d ); do
b=$(echo "$i" | awk '{print substr($1,3); }' )
echo "This file contain <Modified date> <ActualSize Byte> <FullPath>" > "$i"/"$b".txt
find "$i" -type f ! -iname '*thumbs.db*' -print0 | xargs -0 stat -c "%y %s %n" >> "$i"/"$b".txt
done
This is my folders list.
.
./Folder 1
./Folder 2
./Folder 3
The error of script is below.
./xyz.sh: line 4: ./Folder/Folder.txt: No such file or directory
find: ./Folder: No such file or directory
./xyz.sh: line 5: ./Folder/Folder.txt: No such file or directory
./xyz.sh: line 4: 1/.txt: No such file or directory
find: 1: No such file or directory
./xyz.sh: line 5: 1/.txt: No such file or directory
./xyz.sh: line 4: ./Folder/Folder.txt: No such file or directory
find: ./Folder: No such file or directory
./xyz.sh: line 5: ./Folder/Folder.txt: No such file or directory
./xyz.sh: line 4: 2/.txt: No such file or directory
find: 2: No such file or directory
./xyz.sh: line 5: 2/.txt: No such file or directory
./xyz.sh: line 4: ./Folder/Folder.txt: No such file or directory
find: ./Folder: No such file or directory
./xyz.sh: line 5: ./Folder/Folder.txt: No such file or directory
./xyz.sh: line 4: 3/.txt: No such file or directory
find: 3: No such file or directory
./xyz.sh: line 5: 3/.txt: No such file or directory