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.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
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:
Get the longest match of file extension (Ex. For 'foo.tar.gz', you get '.tar.gz' instead of '.gz')
If you have GNU findutils, you can get only the file name with
find /some/path -type f -printf '%f\n'
instead of
find /some/path -type f | gawk -F/ '{print $NF}'
This is a modified version of the OP, wrapped into a bash function.
This version handles newlines and other whitespace correctly, the original has problems with the thankfully rare case of newlines in the file names.
It also allows checking an arbitrary number of directories against each other, which is nice when the directories that you think might have duplicates don't have a convenient common ancestor directory.
Uniq command is mostly used in combination with sort command, as
uniq removes duplicates only from a sorted file. i.e In order for uniq to
work, all the duplicate entries should be in the adjacent lines.
shows number of mysql bin log events (which are mysql server events) per minute, useful to check stress times postmortem
Per country GET report, based on access log. Easy to transform to unique IP
the
find -printf "%f\n" prints just the file name from the given path. This means directory paths which contain extensions will not be considered.
See who is using a specific port. Especially when you're using AIX. In Ubuntu, for example, this can easily be seen with the netstat command.
Detect duplicate UID in you /etc/passwd (or GID in /etc/group file).
Duplicate UID is often forbidden for it can be a security breach.
Reads stdin, and outputs each line only once - without sorting ahead of time. This does use more memory than your system's sort utility.
list top committers (and number of their commits) of svn repository.
in this example it counts revisions of current directory.
Gives the same results as the command by putnamhill using nine less characters.