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.
The output is only partial because runtime dependencies should count in also commands executed via system() and libraries loaded with dlopen(), but at least it gives an idea of what a package directly links to.
Note: this is meaningful *only* if you're using -Wl,--as-needed in your LDFLAGS, otherwise it'll bring you a bunch of false positives.
cat WAR_AND_PEACE_By_LeoTolstoi.txt | tr -cs "[:alnum:]" "\n"| tr "[:lower:]" "[:upper:]" | sort -S16M | uniq -c |sort -nr | cat -n | head -n 30
("sort -S1G" - Linux/GNU sort only) will also do the job but as some drawbacks (caused by space/time complexity of sorting) for bigger files...
Find the source file which contains most number of lines in your workspace