Question : I need to do a report in bash or perl to sum up columns  b for each time column a changes

Sorry, the text is screwed up.  there really are 4 columns here.


what is the easiest way to total up the total column for each "larry",   each "curly" and each "moe".  

I would like to device the sum by 1024000  to turn bytes to MB.  

Tried it with Bash and the results were not good.  Is there a good way to do it in Perl ?  

I tried excel and it munged it up badly.

This will need to be done 4 times a day so I do not want to do it manually :)

client          total  lvl name
larry
larry         2467601228 full /export/workspace
larry         5004202248 full /
larry        13114256440 full /export/workspace1
curly
curly     1436856 full REPAIRDISK:
curly     7250780 full SYSTEM STATE:
curly   620302976 full C:
curly  2391328204 full D:
moe
moe               0 full D:
moe         2450660 full ASR:
moe        18186300 full SYSTEM DB:
moe        19887672 full SYSTEM STATE:
moe       486868636 full SYSTEM FILES:
moe      3814854568 full C:

Answer : I need to do a report in bash or perl to sum up columns  b for each time column a changes

1:
2:
3:
4:
5:
6:
7:
8:
9:
#!/bin/sh
 
FILE=./file.txt
 
for name in `cat ${FILE} | awk '!/^client/ {print $1}' | sort -u`; do
   TOTAL=`echo \`grep "^${name}" file.txt | awk '{print $2}'\` | tr " " "+" | bc`
   TOTAL_MB=`echo "scale=2; $TOTAL/(1024*1024)" | bc`
   echo total_mb for $name: ${TOTAL_MB}
done
Open in New Window Select All
Random Solutions  
 
programming4us programming4us