commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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.
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:
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.