KSH script to get file size for multiple directories
for example if $var="sample" and directories below contain
/u01/test/samples
test1.txt 1GB
test2.txt 1GB
/u04/data/sample
sample2.txt 2Gb
then the script should add up file sizes in those directories and assing them to a variable
So far I came up with something like this:
$dir=/u01/test/samples/*.txt
du -g $dir | total_size=`awk '{c+=$1};END { print c }'`
which works great but only returns total file size for one directory. Can someone help fix my code so that it returns total size fo all directories containing a specific variable in the path?