In the beginning I used TOTAL=`ls /d2lmig/*/*/bak/*/*Â | wc -l` to get a total count. All was good.
Until at around 55,000 files I got:Â -bash: /bin/ls: Argument list too long.
Then I used TOTAL=`find /d2lmig/*/*/bak/*/* -name *.bak | wc -l` to get a total count. All was good.
Until at around 90,000 files I got:Â -bash: /usr/bin/find: Argument list too long.
It happened that I was already using a for do done loop and getting a count for each bak directory. So I added within the for loop:
TOTAL=`expr $TOTAL + $COUNT`
if [ $RUNTYPE = “INTERNAL” ] ; then echo ” Running total = $TOTAL” ; fi
(INTERNAL is a value I pass at the command line that controls whether the email is sent to me or other parties.)
Comment out the TOTAL using find. Voila.
I know, I should have done it this way in the beginning. Sloppy code to go back and get the total. Maybe because I have this post here, I reference it and not be so bad in the future.
Leave a Reply