Commands by toastbrot (1)

What's this? 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 all videos under current directory
Uses mime-type of files rather than relying on file extensions to find files of a certain type. This can obviously be extended to finding files of any other type as well.. like plain text files, audio, etc.. In reference to displaying the total hours of video (which was earlier posted in command line fu, but relied on the user having to supply all possible video file formats) we can now do better: $ find ./ -type f -print0 | xargs -0 file -iNf - | grep video | cut -d: -f1 | xargs -d'\n' /usr/share/doc/mplayer/examples/midentify | grep ID_LENGTH | awk -F "=" '{sum += $2} END {print sum/60/60; print "hours"}'

Determine next available UID
better with accounts on ldap

Create a mirror of a local folder, on a remote server
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22) (all files & folders on destination server/folder will be deleted)

Recursive find and replace file extension / suffix (mass rename files)
Find recursively all files in ~/Notes with the extension '.md' and pipe that via xargs to rename command, which will replace every '.md' to '.txt' in this example (existing files will not be overwritten).

Duplicate installed packages from one machine to the other (RPM-based systems)

Search for a word in less
Although less behaves more or less like vim in certain aspects, the vim regex for word boundaries (\< and \>) do not work in less. Instead, use \b to denote a word boundary. Therefore, if you want to search for, say, the word "exit", but do not want to search for exiting, exits, etc., then surround "exit" with \b. This is useful if you need to search for specific occurrences of a keyword or command. \b can also be used at just the beginning and end, if needed.

Remux an avi video if it won't play easily on your media device
When playback of AVI files (containing a video format like XviD or DivX) is stuttering, it in 90% of the files is caused by a poorly or wrongly interleaved file. The issue can be permanently resolved by RE-MUXING the AVI video-files that have this problem

Create a simple video contact sheet using the vcs bash script
Assumes you've downloaded Toni Corvera's vcs script (, have it in your PATH, and have installed the script's dependencies. Generates a video contact sheet of 24 thumbnails and 3 thumbnails per column. The bold font and white-on-black color scheme keeps the text readable at the chosen 70% JPEG compression quality, which keeps the file size at a manageable level. You can go even lower with the quality and get a good looking result.

Find the package that installed a command

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

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.


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: