Linux Tips - Use DUCKS to get a concise list of files and sizes | ATG Learning

Blog

Linux Tips - Use DUCKS to get a concise list of files and sizes


| Friday, Feb 3, 2017

The Linux du (disk usage) command will output an entire directory tree and every file therein, along with a list of sizes for each file in bytes. Its usefulness can be minimized if you don't know what you're doing with it though. First of all, unless you're dealing exclusively with log or configuration files, filesizes in terms of bytes is not very useful. With your average mp3 file containing 3-5 million of them, across hundreds of files or more these numbers add up quickly. Second, unless you need the output to feed into some other sort of parsing program or script, the information returned is going to whiz by faster than you can conceivably read it, since du looks inside every folder recursively. Sometimes you actually want this data, but in some applications the amount of data you receive back is akin to drinking from a firehose. What do we do about this?

du -cks * | sort -n

Great, another command. What does it do? Let's break it down:

This should help you get a handle on managing files based on size in your filesystem. If you're feeling ambitious, you could even set up an alias to perform this command...something like:

alias ducksort=""du -cks * | sort -n""
Request Information

Please fill out the form below to contact a training consultant directly or call 888-862-3784

Full Name*

Company

Location

Email*

Phone*

Message

Enter the text in the image