This is the command I am using to list some files:
find . -name \*.extract.sys -size +1000000c -exec ls -lrt {} \;
-rw-r--r-- 1 qa1wrk15 test 1265190 Sep 29 01:14 ./var/can/projs/ar/rep/extract/Sep/29/ar.ARAB-PI_7.20110929.extract.sys
-rw-r--r-- 1 qa1wrk15 test 1345554 Sep 29 01:14 ./var/can/projs/ar/rep/extract/Sep/29/ar.ARAB-PI_2.20110929.extract.sys
-rw-r--r-- 1 qa1wrk15 test 1370532 Sep 29 01:14 ./var/can/projs/ar/rep/extract/Sep/29/ar.ARAB-PI_3.20110929.extract.sys
-rw-r--r-- 1 qa1wrk15 test 1399854 Sep 29 01:14 ./var/can/projs/ar/rep/extract/Sep/29/ar.ARAB-PI_8.20110929.extract.sys
and so on.
Now I want to calculate the total size of these files by summing up the 5th column. I thought of using awk, to do this so I tested the following in a particular directory
>ls -lrt | awk `{ print $1 }`
ksh: syntax error at line 1 : `{' unmatched
I don't understand what is the problem, why this syntax error.
I am thinking to try
ls -lrt | awk `BEGIN {total = 0} {for(i=0;i<NR;i++){total+=$5}} END {printf "%d",total}
this also, but a simple awk script is not working.
Please suggest or correct me if I am wrong, or if there is a workaround for this.