I just want to know if it is possible with the below snippet to also assign the count of files matched by find command into the total variable?
total=0
counter=1
while IFS= read -r -d '' file; do
echo "process file $counter of $total"
done < <(find . -iname "*.txt" -type f -print0 | sort -zn)
NOTE: Is it an efficient approach to execute the find command above the loop, and then count the total as well as to use its result in the loop?