我正在尝试查找当前目录的总大小,并且 shell 脚本在 expr 命令中失败。下面是我的代码:
#!/bin/sh
echo "This program summarizes the space size of current directory"
sum=0
for filename in *.sh
do
fsize=`du -b $filename`
echo "file name is: $filename Size is:$fsize"
sum=`expr $sum + $fsize`
done
echo "Total space of the directory is $sum"