WEBTOOLIST.
STATIC WEB PLATFORM
NO ACCOUNTS / NOTHING TO INSTALL

$ webtoolist --script find-large-files

Find Large Files

Locate files above a size threshold and show them largest first.

category File Management shell Bash 4+ updated 2026-07-19
filesdiskfindcleanup
Safety notes
  • Read-only: it only lists files.
  • Avoid running it across network mounts; it can be slow and noisy.

Dependencies: find, sort, numfmt

Usage

  • First argument is the search root (default: current directory).
  • Second argument is the minimum size (default: 100M).

Script

#!/usr/bin/env bash
set -euo pipefail

root="${1:-.}"
min="${2:-100M}"
limit="${LIMIT:-25}"

[[ -d "$root" ]] || { echo "not a directory: $root" >&2; exit 1; }

find "$root" -xdev -type f -size +"$min" -printf '%s\t%p\n' 2>/dev/null \
  | sort -nr \
  | head -n "$limit" \
  | while IFS=$'\t' read -r bytes path; do
      printf '%s\t%s\n' "$(numfmt --to=iec "$bytes")" "$path"
    done

Example

./find-large-files /var 500M
LIMIT=50 ./find-large-files /home 1G

Notes

  • -xdev prevents crossing into mounted filesystems.
  • Delete nothing from the output blindly; check whether a package manager or log rotation owns the file.

Related scripts

Safe Log Cleanup

Delete rotated log files older than a set number of days, with a dry-run first.

System Administration

Archive Old Files

Move files untouched for N days into a dated archive directory.

File Management