It is not so much that it is difficult, but more that it is very unclear what you are trying to achieve?
I mean to combine them I could have simply said:
Code:
for dir in $1; do
echo $dir: $(ls "$dir" | wc -l)
awk '{for (i=1;i<=NF;i++){printf $i };printf "\n"}' < $2 | sort -n | tail -n1
done
But I somehow doubt this is what you are after.