Current directory files and subdirectories ordered by size

du -ks * | sort -n
Very useful for finding the largest files and subdirectories at any given point. Any user can run it from current location just when need to know their largest files and subtdirectories from a certain point down as well.
Sample Output
4	mvc_example.php
72	caseconverter
80	contact
248	hangman

-1
2009-02-16 14:18:52

These Might Interest You

  • zsh globbing and glob qualifier: '**/*' = recursive om = ouput by modification (last access) [1,20] = twenty files. The '-t' switch is provided to ls so that the files are ordered with the most recent at the top. For a more 'find' like output the following can be used. print -rl **/*(om[1,20])


    0
    ls -tl **/*(om[1,20])
    khayyam · 2013-03-24 00:14:03 0
  • Sort ls output of all files in current directory in ascending order Just the 20 biggest ones: ls -la | sort -k 5bn | tail -n 20 A variant for the current directory tree with subdirectories and pretty columns is: find . -type f -print0 | xargs -0 ls -la | sort -k 5bn | column -t And finding the subdirectories consuming the most space with displayed block size 1k: du -sk ./* | sort -k 1bn | column -t


    6
    ls -la | sort -k 5bn
    masterofdisaster · 2009-06-07 14:35:17 3
  • Provides a recursive time ordered list of the current directory over the last 3 minutes. Excluding zero byte files: ls -lF -darth `find . -size +0 -mmin -3` For the last day's files, change "-mmin -3" to "-mtime -1": ls -lF -darth `find . -size +0 -mtime -1` Show Sample Output


    -2
    ls -lF -darth `find . -mmin -3`
    UncleLouie · 2014-03-22 16:52:20 0
  • Prints the sizes of all the subdirectories (sorted by size), similar to Treesize utility. https://superuser.com/questions/554319/bash-display-each-sub-directory-size-in-a-list-format-using-1-line-command Show Sample Output


    0
    du -h --max-depth=1 | sort -hr
    mayurpant · 2018-01-04 07:31:47 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: