深度阅读

How do I sort files by size using the ls command in Linux?

作者
作者
2023年08月22日
更新时间
5.95 分钟
阅读时间
0
阅读量

To sort files by size using the ls command in Linux, you can use the -S option. Here’s an example:

ls -lS

This will list all files in the current directory, sorted by size with the largest file shown at the top. You can also use other options with the ls command, such as -h to display the file sizes in human-readable format, or -r to reverse the order of the listing. For example:

ls -lhSr

This command will show all files in the current directory, sorted by size with the smallest file shown at the top, and the file sizes displayed in a human-readable format.

相关标签

博客作者

热爱技术,乐于分享,持续学习。专注于Web开发、系统架构设计和人工智能领域。