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:
the output of svn log is annoying to grep, since it spreads the useful info over multiple lines. This compacts the output down to one line so eg you can grep for a comment and see the rev, date & committer straight away.
Updated: MUCH shorter, easier to remember. Now it just replaces newlines with spaces, except on '---' lines.
added greedy trick in wildcard match (.*?) from
say only processes a complete file, at eof, so following a file isn't possible. Quick and dirty perl oneliner to feed each line from the tail -f to say. Yes, expensive to lauch a new process each line.
This little ditty was prompted by a discussion on how horrible it is to use VoiceOver on ncurses programs such as irssi.
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 :-)