目录中所有文件内容的总大小

编程入门 行业动态 更新时间:2024-10-23 02:03:48
本文介绍了目录中所有文件内容的总大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我使用ls或du时,我将获得每个文件占用的磁盘空间量.

When I use ls or du, I get the amount of disk space each file is occupying.

我需要打开每个文件并计算字节数后得到的文件和子目录中所有数据的总和.如果我能在不打开每个文件也不计数的情况下获得此奖励积分.

I need the sum total of all the data in files and subdirectories I would get if I opened each file and counted the bytes. Bonus points if I can get this without opening each file and counting.

推荐答案

如果要表观大小"(即每个文件中的字节数),而不是磁盘上文件占用的大小,请使用-b或--bytes选项(如果您的Linux系统具有GNU coreutils ):

If you want the 'apparent size' (that is the number of bytes in each file), not size taken up by files on the disk, use the -b or --bytes option (if you got a Linux system with GNU coreutils):

% du -sbh <directory>

更多推荐

目录中所有文件内容的总大小

本文发布于:2023-11-01 20:19:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550315.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大小   文件   内容   目录中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!