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:
Find which directories on your system contain a lot of files.
Edit: much shorter and betterer with -n switch.
PmWiki stores wiki pages as Group.Name. Simply split the directory listing and count frequency of group occurances.
This version now adds a header with consecutive numbering.
Before running, do:
curl -sO http://world.std.com/%7Ereinhold/diceware.wordlist.asc
Lets say you have a file with the following layout:
LINUX,DIR,FILE1,FILE2,FILE3
You want the file to look like this:
LINUX,DIR,FILE1
LINUX,DIR,FILE2
LINUX,DIR,FILE3
This perl command does it for you.
I use this in my bashrc to expand hosts defined in ~/.ssh/config:
function _ssh_completion() {
perl -ne 'print "$1 " if /^Host (.+)$/' ~/.ssh/config
}
complete -W "$(_ssh_completion)" ssh
Here's a great article on how to setup your own ~/.ssh/config:
http://blogs.perl.org/users/smylers/2011/08/ssh-productivity-tips.html
Find all files in /var/spool/mqueue older than 7 days, pass to perl to efficiently delete them (faster than xargs or -exec when you've got millions or hundreds of thousands to delete). Naturally the type, directory, and file age vars can be adjusted to meet your specific needs.
Can be run as a script `ftrace` if my_command is substrituted with "$@"
It is useful when running a command that fails and you have the feeling it is accessing a file you are not aware of.
If you've ever tried "grep -P" you know how terrible it is. Even the man page describes it as "highly experimental". This function will let you 'grep' pipes and files using Perl syntax for regular expressions.
The first argument is the pattern, e.g. '/foo/'. The second argument is a filename (optional).
this command example converts to 25 fps subtitles that were originally created for 24 fps movie
more idiomatic version of the same, using the flip-flop-operator; also printing lines with '//'-style comments
This is a naive way of finding source code comments in source code files that use C-like comments: // and /*...*/
Using tail to follow and standard perl to count and print the lps when lines are written to the logfile.
Replace PACKAGE with desired package name.
Found here: http://mikebeach.org/2011/04/undo-apt-get-build-dep/
This is from perldoc -q random.*line, which says:
This has a significant advantage in space over reading the whole file in. You can find a proof of this method in The Art of Computer Programming, Volume 2, Section 3.4.2, by Donald E. Knuth.
Who am I to argue with Don Knuth?