calculate sum size of files by date (arg list too long)

Hi,
I wanted a script to find sum of files for a particular date, below is my script

ls -lrt *.req | nawk '$6 == "Aug"' | nawk '$7 == "1"'| awk '{sum = sum + $5} END {print sum}' 

However, i get the error below
/usr/bin/ls: arg list too long

How do i fix that.
Many thanks before.

This is one way, and avoids the extra awk processes:

ls -lrt | awk '
        /.req$/ {
                if( $6 == "Aug" && $7+0 == 1 )
                        sum = sum + $5;
        }

        END {
               print sum+0
        }'

1 Like

Hi agama,

Thanks. It works perfectly.:b: