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:
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 uses wget instead of curl
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.
Much better alternatives - grep-alikes using perl regexps. With more options, and nicer outputs.
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
The output of lsof is piped to txt2html which converts it to html.
# Perl module HTML::TextToHTML needed
If your contact information was entered when your user account was created (it gets added to /etc/passwd) then this gets that info and creates a QR code for you automatically
Randomizes a file. The opposite of sort is sort -R!
The same with colors
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.
Recursively delete empty directories. Use with care.
This uses Perl's rename utility (you may have to call it as prename on your box) and won't choke on spaces or other characters in filenames. It will also zero pad a number even in filenames like "vacation-4.jpg".
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?
Let -p do it's voodoo and do absolutely nothing but set the output record separator :-)
Reads stdin, and outputs each line only once - without sorting ahead of time. This does use more memory than your system's sort utility.
This works by reading in two lines of input, turning each into a list of one-character matches that are sorted and compared.