commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
no fancy grep stuff here.
Since coreutils 7.6 provides sort -h
Calculates the size on disk for each package installed on the filesystem (or removed but not purged). This is missing the
| sort -rn
which would put the biggest packges on top. That was purposely left out as the command is slightly on the slow side
Also you may need to run this as root as some files can only be checked by du if you can read them ;)
use "watch" instead of while-loops in these simple cases
Got a file you're generating and you want the size without typing in 'ls -l file' all the time? Use this instead.
A little bit smaller, faster and should handle files with special characters in the name.
Based on the MrMerry one, just add some visuals to differentiate files and directories
Based on the MrMerry one, just add some visuals and sort directory and files
biggest->small directories, then biggest->smallest files
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
du only accepts lines ending with a NUL, which can be a pain to create. This solves that issue.
This allows the output to be sorted from largest to smallest in human readable format.
This command produces the output of "du -sk testfile" in every 10 seconds. You can change the command to be whatever you want.
OSX's BSD version of the du command uses the -d argument instead of --max-depth.
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.