I could potentially be handling hundreds of files so if I understand the -exec command, this wouldn't work.
However I can't get the while loop working.
Originally Posted by
steeldriver
Try
Code:
while read -r -d $'\0' i; do
echo "$i";
done < <(find . -name '*.txt' -print0)
The above produces a redirection error.
Code:
while read -r -d $'\0' i; do
echo "$i";
done < $(find . -name '*.txt' -print0)
This still concatenates the filenames together. And looks like it's trying to execute the file.
I don't really understand what the above is doing so if I simplify it down, I get the below which still doesn't work;
Code:
while read i; do
echo $i;
done < $(find . -name '*.jpg')
Code:
rhys@Orange:~/Documents/Scripts$ ./exists
./exists: 3: ./exists: cannot open ./flac_music/Evanescence/folder.jpg
./flac_music/Evanescence/fanart.jpg
./flac_music/Evanescence/Fallen/folder.jpg: No such file
But it got me thinking, I could output the result of the find into a text file and then read the text file in one by one.
Code:
find . -name '*.jpg' -print > ./file.txt
while read i
do
echo $i
echo "file processed"
done <file.txt
This has also given me the idea of producing a log file. What fun lies ahead.
I'm still interested to know what I'm doing wrong on the loops though.
Bookmarks