I'm struggling immensely with getting a nested for loop to work for this. The data set I am working with is very large (a little over a million files).
I was looking at a nested for loop but it seems unstable.
count=0
for dir in $(find "$sourceDir" -mindepth 1 -maxdepth 1 -type d)
do
(
mkdir -p "$destDir/$dir"
for file in $(find . -type f)
do
(
if [ $((count % 3)) -eq 2 ]
then
cp -prl "$file" $destDir/$dir
fi
((count ++))
)
done
)
((count++))
done
^^ this is only going into the last directory and finding the 3rd file. I need it to enter every directory and find the third file
I've thought of breaking this up into chunks and running several scripts instead of just one to make it more scalable.