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:
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
This alternative cleans HISTTIMEFORMAT environment variable and calls gnuplot just after /tmp/cmds is closed, to avoid some errors.
Plot your most used commands with gnuplot.
Finds all files below the current directory.
Orders the result from smallest to largest.
Good for finding the largest files in the tree.
find OGG audio files on your *nix box and listen to them using your web browser
print members both in file1 and file2
Here's a version that doesn't use find.
with grep for em:name rather than name, you will get much better result.
Extracts ip addressess from file using sed. Uses a tag(ip) to grep the IP lines after extracting. Must be a way to just output regex matched on sed.
This provides a way to sort output based on the length of the line, so that shorter lines appear before longer lines. It's an addon to the sort that I've wanted for years, sometimes it's very useful. Taken from my http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
1.) my profile ends with $USER not with .default
2.) only grep for the first occurrence because some extensions have the translated name also inside the install.rdf
first 10 big file
What was the name of that module we wrote and deleted about 3 months ago? windowing-something?
git log --all --pretty=format:" " --name-only | sort -u | grep -i window
Counts TCP states from Netstat and displays in an ordered list.
The same as the other two alternatives, but now less forking! Instead of using '\;' to mark the end of an -exec command in GNU find, you can simply use '+' and it'll run the command only once with all the files as arguments.
This has two benefits over the xargs version: it's easier to read and spaces in the filesnames work automatically (no -print0). [Oh, and there's one less fork, if you care about such things. But, then again, one is equal to zero for sufficiently large values of zero.]