I have a base directory with a set of subdirs inside, some of those dirs have files with extension of jpg. I want to copy those files to another dir, this is my objective. I decided to assign the value of find to a list variable and then iterate over the list and copy the source file to target destination.
mylist=$(find . -type f -name "*.png")
As you can tell the mylist var will have only one element. It will be string containing all the different files found, and there are a lot of files inside the index 0.
I have tried to use the following method to separate the lines on by one onto a new array
while IFS= read -r line; do
files+=( "$line" )
done <"$mylist"
However this did not work and just dumps all the lines from the result of the find.
I am using bash 3.2 in MacOS.I would like to know how can I parse the $mylist var so that I could have another variable with a file path in each index. Or as an alternative to make the result of the find command into a list right after the execution