Linux Shell打印文件大小

项目对编译好的文件大小有限制,为了方便,搞了个shell,每次编译完成自动输出文件大小。如下:

printFileSize()
{  
    
	for fname in "$@" 
	do 
		filesize=`ls -l $fname | awk '{ print $5 }'`
		kb=1024
		awk 'BEGIN{printf "'$fname' size is %.2f kb\n",('$filesize'/'$kb')}'
	done
 
 
}


echo "\n"
printFileSize app.img rtthread.bin

显示

app.img size is 701.80 kb
rtthread.bin size is 1040.00 kb

你可能感兴趣的:(Shell)