#!/bin/sh
sum=0
lineCount=0
homeDir="/home/imagemedia/ytsp/videoGSX/"
tempDir=""
tempResult=""
while read -r line
do
tempDir=${line#*//}
tempDir=${tempDir#*/}
tempDir=$homeDir$tempDir
tempResult=$(du -sh $tempDir)
size=${tempResult%M*}
let lineCount++
sum=`echo "$size + $sum"|bc`
echo $size
done<"/home/imagemedia/ytsp/log2.txt"
echo "$lineCount rows"
echo -n "$sum M"
echo
执行方式:bash xxx.sh