Back to lessons

Linux Survival Basics

Show Big Files in Human Units

You need to find large files and read their sizes without mentally converting bytes.

Command

find /var -type f -printf '%s %p\n' | sort -nr | head -10 | awk '{printf "%.1f MB %s\n", $1/1024/1024, $2}'

What changed

Nothing changes. The command converts byte counts into MB for quick triage.

Danger

safe

When to use it

Use this when disk cleanup needs fast human-readable ranking.

When not to use it

Do not delete files from this list without checking ownership and purpose.

Undo or recovery

No state is changed.

Expected output

Large files listed with approximate MB sizes.

demo script

Disposable terminal steps

  1. find /var -type f -printf '%s %p\n' | sort -nr | head -10
  2. find /var -type f -printf '%s %p\n' | sort -nr | head -10 | awk '{printf "%.1f MB %s\n", $1/1024/1024, $2}'
  3. du -sh /var/* 2>/dev/null | sort -h

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ find /var -type f -printf '%s %p\n' | sort -nr | head -10
196608 /var/cache/demo/blob.cache
98304 /var/log/app.log
65536 /var/backups/site.tar
::exit-code::0
$ find /var -type f -printf '%s %p\n' | sort -nr | head -10 | awk '{printf "%.1f MB %s\n", $1/1024/1024, $2}'
0.2 MB /var/cache/demo/blob.cache
0.1 MB /var/log/app.log
0.1 MB /var/backups/site.tar
::exit-code::0
$ du -sh /var/* 2>/dev/null | sort -h
64K	/var/backups
96K	/var/log
192K	/var/cache
::exit-code::0

YouTube Short

Show big files in MB.

Finding large files is useful. Making the sizes readable makes the next decision faster.

LinkedIn hook

Byte counts are precise. Human units are faster under pressure.

Question: Do you prefer raw bytes or human units during disk cleanup?

experiments

A/B tests to run

Metric: youtube_retention_15s

A: Show big files in human units.

B: Byte counts are precise, but MB is faster.