Commands by mdix (1)

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

Find the package that installed a command

split a multi-page PDF into separate files
Have to do this once per output file, because if device is 'pdfwrite', even if 'gs' sees '%d' in the OutputFile it still only creates one single output file. Embed it into a simple shell script if you want to split a document out into one file for every page.

Automatically rename tmux window using the current working directory
Adds a function that runs every time the prompt is rendered. The function grabs the CWD from PWD and issues a command to tmux to change the current window

Find files with lines that do not match a pattern
This one would be much faster, as it's only one executed command.

list block devices
Shows all block devices in a tree with descruptions of what they are.

Quick and dirty convert to flash
This converts any media ffmpeg handles to flash. It would actually convert anything to anything, it's based on the file extension. It doesn't do ANY quality control, sizing, etc, it just does what it thinks is best. I needed an flv for testing, and this spits one out easily.

Create a system overview dashboard on F12 key
Command binds a set of commands to the F12 key. Feel free to alter the dashboard according to your own needs. How to find the key codes? Type $ read Then press the desired key (example: F5) $ ^[[15~ Try $ bind '"\e[15~"':"\"ssh su@ip-address\C-m""" or $ bind '"\e[16~"':"\"apachectl -k restart\C-m"""

get stdout to variable and stdout at sametime
Sometimes you want to write the script output to stdout but you need to send it to email. If you use: $ var="$( ls / )"; $ echo -e "$var"; works but, you need to wait the script terminate to bufferize then print the output var; With this way, you can use/work/print the output before the variable receive all the output content, then after it you can use the variable for anything else, like send email.

Pick a random line from a file
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?

Cleanup firefox's database.
For Mac OS X users only


Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: