Technology Encyclopedia Home >How to find large files on the file system?

How to find large files on the file system?

To find large files on a file system, you can use command-line tools depending on your operating system.

On Linux/macOS:

Use the find command with size filters. For example:

find /path/to/search -type f -size +100M
  • /path/to/search: Replace with the directory you want to scan (e.g., /home or /).
  • -type f: Ensures only files are listed (not directories).
  • -size +100M: Finds files larger than 100MB (adjust size as needed, e.g., +1G for files >1GB).

Example:

find /var/log -type f -size +500M

This finds log files larger than 500MB in /var/log.

On Windows:

Use PowerShell with the Get-ChildItem cmdlet:

Get-ChildItem -Path "C:\path\to\search" -Recurse -File | Where-Object { $_.Length -gt 100MB }
  • -Recurse: Searches subdirectories.
  • -File: Filters for files only.
  • $_.Length -gt 100MB: Finds files larger than 100MB.

Example:

Get-ChildItem -Path "D:\Downloads" -Recurse -File | Where-Object { $_.Length -gt 2GB }

This finds files larger than 2GB in the D:\Downloads folder.

Using Tencent Cloud Services (if applicable):

If you're managing files on Tencent Cloud Object Storage (COS), use the COS Console or COSCMD tool to list and filter large files. For example:

coscmd list -ar /bucket/path/ | grep -E "^[0-9]+[MGTP]"

This helps identify large objects stored in COS buckets. For automated management, consider Tencent Cloud SCF (Serverless Cloud Function) to trigger file-size checks periodically.