COMMAND LINE KUNG FU

Lệnh Linux tìm file lớn hơn kích thước nào đó Gigabyte/Megabyte/Kilobyte

694
author Bùi Tấn Việt - 2022-07-14 09:33:06 (GMT+7)

Lệnh find với đối số -size sẽ giúp bạn tìm file có kích thước nào đó. Ví dụ:

Lệnh tìm file lớn hơn 1GB

bash (non-root)
find /var/log/ -type f -size +1G
/var/log/httpd/error_log-20220626
/var/log/httpd/error_log
/var/log/httpd/error_log-20220703
/var/log/httpd/error_log-20220710
  • find: Lệnh tìm file
  • /var/log/: Tìm file trong thư mục này
  • -type f: Chỉ định chỉ tìm file (bỏ qua thư mục)
  • -size +1G: Chỉ tìm file lớn hơn 1GB. Ngoài G, bạn có thể sử dụng M (Megabyte), hoặc K (Kilobyte).

Lệnh tìm file lớn hơn 1GB và in ra dung lượng của từng file

bash (non-root)
find /var/log/ -type f -size +1G -exec ls -lh {} \; | awk '{ print $9 "|| File Size : " $5 }'
/var/log/httpd/error_log-20220626|| File Size : 1.6G
/var/log/httpd/error_log|| File Size : 2.9G
/var/log/httpd/error_log-20220703|| File Size : 3.6G
/var/log/httpd/error_log-20220710|| File Size : 4.1G

Lệnh tìm file lớn hơn 100MB

bash (non-root)
find /var/log/ -type f -size +100M
/var/log/messages-20220703
/var/log/messages-20220619
/var/log/messages
/var/log/messages-20220626
/var/log/directadmin/errortaskq.log-20220703
/var/log/directadmin/errortaskq.log-20220710
/var/log/messages-20220710

Bạn có làm được theo hướng dẫn này không?

Lệnh liên quan

Object Storage

Chuẩn S3, không giới hạn băng thông

Object Storage
Thông tin tác giả
Bùi Tấn Việt

Co-Founder & CEO at 123HOST

Bình luận

Tính năng đang được phát triển

Đang tải bình luận
Liên hệ chúng tôi