Excludes other mountpoints with acavagni's "mountpoint" idea, but with -exec instead of piping to an xargs subshell. Then, calling "du" only once with -exec's "+" option. The first "\! -exec" acts as a test so only those who match are passed to the second "-exec" for du. Show Sample Output
Use the find command to match certain files and summarise their total size in KBytes. Show Sample Output
When you've got a list of numbers each on its row, the ECHO command puts them on a simple line, separated by space. You can then substitute the spaces with an operator. Finally, pipe it to the BC program. Show Sample Output
get diskusage of files (in this case logfiles in /var/log) modified during the last n days:
sudo find /var/log/ -mtime -n -type f | xargs du -ch
n -> last modified n*24 hours ago
Numeric arguments can be specified as
+n for greater than n,
-n for less than n,
n for exactly n.
=> so 7*24 hours (about 7 days) is -7
sudo find /var/log/ -mtime -7 -type f | xargs du -ch | tail -n1
Show Sample Output
Based on the MrMerry one, just add some visuals and sort directory and files
no fancy grep stuff here.
The original didn't use -print0 which fails on weird file names eg with spaces. The original parsed the output of 'ls -l' which is always a bad idea.
Even simpler! Use du ... the -s and -c flags summarize and print a grand total of all files recursively. The -b flag prints in byte format. You can use the -h flag instead to print in human readable format. Show Sample Output
Specify the size in bytes using the 'c' option for the -size flag. The + sign reads as "bigger than". Then execute du on the list; sort in reverse mode and show the first 10 occurrences. Show Sample Output
Use this to find identify if dirs mostly contain large or small files. Show Sample Output
I had the problem that our monitoring showed that the "/" filesystem is >90% full. This command helped me to find out fast which subdirs are the biggest. The system has many NFS-mounts therefore the -x.
Show sizes of all files and directories in a directory in size order.
du -hs * | sort -hr
for reverse order.
Taken from http://serverfault.com/questions/62411/how-can-i-sort-du-h-output-by-size
Show Sample Output
list the top 15 folders by decreasing size in MB Show Sample Output
This command is useful for finding out which directories below the current location use the most space. It is summarised by directory and excludes mounted filesystems. Finally it is sorted by size. Show Sample Output
Tested on MacOS and GNU/Linux. It works in dirs containing files starting with '-'. It runs 'du' only once. It sorts according to size. It treats 1K=1000 (and not 1024) Show Sample Output
Same result as with 'du -ks .[^.]* * | sort -n' but with size outputs in human readable format (e.g., 1K 234M 2G)
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.
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
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: