Linux 下按照文件大小查找文件
为什么需要这篇文章
我想大概是这种情况,你的Linux 机器下磁盘满了,需要清理,然后就需要查找大的文件,确定是否有用进行删除。
具体做法
查找500M以上的文件
1
2
3
4
5
6
7
| sudo find / -size +500M
/swap.img
/home/androidyue/file_server/ubuntu_18.04.tar
/home/androidyue/bin/TeamCity-2019.2.2.tar.gz
/proc/kcore
find: ‘/proc/23619’: No such file or directory
|
查找整整500M的文件
查找小于500M的文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| sudo find / -size -500M
/
/opt
/opt/containerd
/opt/containerd/lib
/opt/containerd/bin
/opt/gitlab
/opt/gitlab/sv
/opt/gitlab/sv/prometheus
/opt/gitlab/sv/prometheus/log
/opt/gitlab/sv/prometheus/log/run
/opt/gitlab/sv/prometheus/log/main
/opt/gitlab/sv/prometheus/log/supervise
/opt/gitlab/sv/prometheus/log/supervise/stat
/opt/gitlab/sv/prometheus/log/supervise/status
/opt/gitlab/sv/prometheus/log/supervise/pid
/opt/gitlab/sv/prometheus/log/supervise/lock
/opt/gitlab/sv/prometheus/log/supervise/ok
/opt/gitlab/sv/prometheus/log/supervise/control
/opt/gitlab/sv/prometheus/run
/opt/gitlab/sv/prometheus/env
|
查找大于100M且小于500M的文件
1
2
3
4
| sudo find / -size -500M -size +100M
/sys/devices/pci0000:00/0000:00:02.0/resource2_wc
/sys/devices/pci0000:00/0000:00:02.0/resource2
/usr/bin/dockerd
|
其他查找单位
- b – for 512-byte blocks (this is the default if no suffix is used)
- c – for bytes
- w – for two-byte words
- k – for Kilobytes
- M – for Megabytes
- G – for Gigabytes
References
快来解锁最新版 Typora,新用户券后仅需 84 元!
如何便宜的购买 office 365 ?
新版赤友 NTFS 助手来袭,正版超低价