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:
sudo is optional, but to find out about all files, it is nice, or else run as superuser, ie: su -c 'du -sm * | sort -n'
Works in sort (GNU coreutils) 7.4, don't know when it was implemented but sometime the last 6 years.
This command is primarily going to work on linux boxes.
and needs to be changed, for example
Supports other file formats.
the comm utility (opposite of diff) show commonalities in files (in this case strings)
If your grep doesn't have an -o option, you can use sed instead.
Just a little simplification.
Gets the authors, sorts by number of commits (as a vague way of estimating how much of the project is their work, i.e. the higher in the list, the more they've done) and then outputs the results.
Use this BASH trick to create a variable containing the TAB character and pass it as the argument to sort, join, cut and other commands which don't understand the \t notation.
sort -t $'\t' ...
join -t $'\t' ...
cut -d $'\t' ...
Displays a connection histogram of active tcp connections. Works even better under an alias. Thanks @Areis1 for sharing this one.
Shows a list of users that currently running processes are executing as.
YMMV regarding ps and it's many variants. For example, you might need:
ps -axgu | cut -f1 -d' ' | sort -u
Most systems (at least my macbook) have system users defined, such as _www and using "users" for example will not list them. This command allows you to see who the 'virtual' users are on your system.
We normally get tasks in which one has to sort a data file according to some column. For a single file say foo, we would use
sort -k 3 foo >tmp && tmp foo
The for loop is useful when we have to do it on a number of files.