1 hour ago · Tech · hide · 0 comments

Got a directory that you want to tidy up bloat from? Whether you’re trying to find bad build artifacts in your work repository or clear out old cat videos from your home directory, Zsh’s (OL) glob qualifier can help you find the largest files. Using the Django source repository as an example, here’s how we can show the size of the five largest files: $ du -h **/*(.OL[1,5]) 696K tests/gis_tests/data/rasters/raster.numpy.txt 492K docs/_theme/djangodocs/static/fontawesome/webfonts/fa-brands-400.svg 440K Django.egg-info/SOURCES.txt 396K tests/admin_views/tests.py 320K build/lib/django/contrib/admin/static/admin/js/vendor/xregexp/xregexp.js Glob qualifier syntax is dense. Let’s break it down: du -h: du reports the disk usage of each file, and its -h option makes the sizes human-readable (KiB, MiB, etc.) **/*: a recursive glob pattern that matches all files in the current directory and its subdirectories. (): parentheses following a glob pattern contain the glob qualifiers, which filter and…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.