13

Mac/Linux 根据大小查找文件

 3 years ago
source link: https://xmanyou.com/mac-find-file-by-size/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
25 February 2021 / mac

Mac/Linux 根据大小查找文件

利用find命令,可以查找相应大小的文件

find <path> -type f -size <size filter>

查找并列出所有文件的详细路径,则可以加上 -exec ls -l {} +

find <path> -type f -size <size filter> -exec ls -l {} +

其中,size filter的格式:

  • 大于: +size
  • 小于: -size
  • 等于: size

size呢,则是由数字加上单位构成,单位包括:

  • b : 512字节的块(block)
  • c : 1个字节
  • w : 2个字节(word)

举几个例子

  1. 查找0字节文件
find . -type f -size 0 -exec ls -l {} +
  1. 查找在10M和20M之间的文件
find . -type f -size +10M -size -20M

阿斌

Read more posts by this author.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK