shell获取文件大小_从Shell获取目录大小

shell获取文件大小

My first goal when coding is usually to make it work and then clean up the code into a more maintainable format.  Many people prefer to keep code clean from start to finish but thinking "maintenance first" slows me down --- I like to GO GO GO!  Sometimes making code means the code size gets larger, sometimes it means getting smaller.

编写代码时,我的首要目标通常是使其工作,然后将代码整理成更易于维护的格式。 许多人更喜欢从头到尾保持代码整洁,但是认为“维护第一”会使我慢下来---我喜欢GO GO GO! 有时制作代码意味着代码大小变大,有时意味着变小。

Oftentimes when I'm trying to abstract my CSS preprocessing code (Stylus), I abstract my mixins but want end up with the exact same CSS output.  What's the easiest way to check that the outcome is likely the same, without scouring the site and checking every section?  Checking the output directory size.  If the CSS code is the same size before and after changes, we're golden!  So how do we check directory size?

通常,当我尝试抽象我CSS预处理代码(Stylus)时,我抽象了我的mixins,但希望最终得到完全相同CSS输出。 在不检查站点和检查每个部分的情况下,最简单的方法来检查结果是否可能相同? 检查输出目录大小。 如果CSS代码更改前后的大小相同,那么我们就很成功了! 那么我们如何检查目录大小?


du -s 		# 16075464, recursive
du -sh 		# 7.7G, recursive, human readable


The commands above provide the directory size in different formats.  If you want to get the exact byte size of a directory, you can execute this slightly more complicated command:

上面的命令以不同的格式提供目录大小。 如果要获取目录的确切字节大小,可以执行以下稍微复杂一些的命令


find . -type f -exec ls -l {} \; | awk '{sum += $5} END {print sum}' # 8209358267


Of course something flukey could happen and the CSS change with the exact same size coming out, but this method isn't meant to be scientific.  And remember that these commands can be used for any number of purposes!

当然,可能会出现一些问题,并且CSS会以完全相同的大小发生变化,但是这种方法并不意味着科学。 请记住,这些命令可用于多种用途!

翻译自: https://davidwalsh.name/directory-size

shell获取文件大小

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值