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

Remove all files but one starting with a letter(s)
Remove everything in current directory except files starting with "ca".

Quickly create simple text file from command line w/o using vi/emacs
1. Issue command 2. After angled bracket appears, enter file contents 3. When done, type "EOF"

Console clock
A console clock with the current time.

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

apt-get via sudo
An apt-get wrapper function which will run the command via sudo, but will run it normally if you're only downloading source files. This was a bit of an excuse to show off the framework of $ cmd && echo true || echo false ...but as you can see, you must be careful about what is in the "true" block to make sure it executes without error, otherwise the "false" block will be executed. To allow the apt-get return code to pass through, you need to use a more normal if/else block: $ apt-get () { if [ "$1" = source ]; then command apt-get "$@"; else sudo apt-get "$@"; fi }

SSH connection through host in the middle
Unreachable_host is unavailable from local network, but it's available from reachable_host's network. This command creates a connection to unreachable_host through "hidden" connection to reachable_host.

Draw kernel module dependancy graph.
parse "lsmod" output to "dot" format and pass it to "display". Without perl!

Extract the emoticons regex from a running skype process
Skype has an internal regex which depicts the emoticons it supports. However you cannot simply search the binary file for it. This small 181 character line will do just that, provided skype is running. And of course, only works in linux.

Calculate days on which Friday the 13th occurs
I removed the dependency of the English language

function to verify an IP address - can be used at the shell prompt or in a shell script
When processing IP addresses in the shell (or shell script) it is useful to be able to verify that the value of data is an IP address (an not some random string or non-sensible IP address).


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: