Using find and grep to fill an array
In bash I am trying to create an array of pathnames for zero sized files.
I use
find . -size 0
which gives me a list of files and their paths. So the conclusion is:
./001/013/fileA ./001/014/fileB ./002/077/fileA
Now I want an array that I can loop through, for example:
(001/013 001/014 002/077)
I've tried this:
folderlist=($(find . -size 0 | grep '\<[0-9][0-9][0-9][/][0-9][0-9][0-9]\>' ))
for i in "${folderlist[@]}"
do
echo $i
done
But the exit is empty.
What am I missing?
Thank you so much!
+3
source to share
2 answers