All commands (14,187)

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

Convert encoding from cp1252 (MS Windows) to UTF-8 on source code files

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

function to compute what percentage of X is Y? Where percent/100 = X/Y => percent=100*X/Y
This function make it easy to compute X/Y as a percentage. The name "wpoxiy" is an acronym of "what percentage of X is Y"

Replace strings in text
-e is the script function, it performs search and replace like vi, and -i is the edit the file in place.

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Run the built in PHP-server in current folder
You must have PHP 5.4.0 or later to be able to run the built in server. This web server is designed for developmental purposes only, and should not be used in production. URI requests are served from the current working directory where PHP was started, unless the -t option is used to specify an explicit document root. If a URI request does not specify a file, then either index.php or index.html in the given directory are returned. If neither file exists, then a 404 response code is returned. If a PHP file is given on the command line when the web server is started it is treated as a "router" script. The script is run at the start of each HTTP request. If this script returns FALSE, then the requested resource is returned as-is. Otherwise the script's output is returned to the browser. Standard MIME types are returned for files with extensions: .css, .gif, .htm, .html, .jpe, .jpeg, .jpg, .js, .png, .svg, and .txt. The .htm and .svg extensions are recognized from PHP 5.4.4 onwards. More information here: http://php.net/manual/en/features.commandline.webserver.php

Get a regular updated list of zombies
to omit "grep -v", put some brackets around a single character

A video capture command which can be assigned to a keyboard shortcut.
A video capture command which can be assigned to a keyboard shortcut.

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

Shuffle mp3 files in current folder and play them.
* grep -i leaves only mp3 files (case insentitive) * sort -R randomizes list (may use GNU 'shuf' instead). * the sed command will add double quotes around each filename (needed if odd characters are present)


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: