简体   繁体   English

如何在Linux中列出目录中的文件和文件夹及其总大小?

[英]How to list the files and folders in a directory with its total size in Linux?

I can't get any command to list all the files and folders with its total size in a directory without showing all the sub-directories. 我无法在不显示所有子目录的情况下获得任何命令来列出目录中所有文件和文件夹的总大小。 eg I have a directory as 例如我有一个目录

ls /home/kayan/data/
data-1 data-2 test.txt readme.txt

here data-1 and data-2 are two folder having plenty of sub-folders and files. 这里data-1和data-2是两个文件夹,其中包含许多子文件夹和文件。 Their actual sizes are 123G and 115G. 它们的实际大小是123G和115G。

When I am using "du" command it is listing all the sub-directories and taking too much time. 当我使用“ du”命令时,它列出了所有子目录,并且花费了太多时间。 When I am using "ll" it is not showing the actual size of a folder which has sub-folders. 当我使用“ ll”时,它没有显示具有子文件夹的文件夹的实际大小。 What I want is like something: 我想要的是某种东西:

data-1 123G
data-2 115G
test.txt 12K
readme.txt 14K

You can use "du" command to achieve that. 您可以使用“ du”命令来实现。 Go to the right directory and type 转到正确的目录并键入

du -sh *

It will list all files and directories in the current directory like 它将列出当前目录中的所有文件和目录,例如

123G data-1
115G data-2
12K test.txt
14K readme.txt

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Linux:如何列出有关文件或目录的信息(大小,权限,按类型划分的文件数?) - Linux:How to list the information about file or directory(size,permission,number of files by type?) in total Linux Bash 脚本:获取给定目录中“png”和“gif”文件的总大小,然后比较大小 - Linux Bash Scripting: Obtain the total size of 'png' and 'gif' files in a given Directory then compare the size 如何在Linux上的目录中找到csv文件的总行数? - How to find the total lines of csv files in a directory on Linux? 如何在linux中仅递归计算某些文件的总大小 - How to calculate the total size of certain files only, recursive, in linux 如何列出 Linux 终端中大小/长度为零的目录中的文件? - How can I list the files in a directory that have zero size/length in the Linux terminal? 如何递归获取目录下所有文件的总大小 - How to get total size of all files recursively under directory 使用完整路径计算生成的文件夹列表中所有文件的总大小 - Calculate the total size of all files from a generated folders list with full PATH linux文件和文件夹未继承父目录权限 - linux files and folders are not inheriting parent directory permissions Linux 中的一个脚本,用于查看已删除文件的总大小 - A script in Linux to view total size of removed files 如何使用linux cmd列出linux中所有目录中的所有文件 - How to list all files in all directory in linux using linux cmd
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM