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

Multi-line grep
Using perl you can search for patterns spanning several lines, a thing that grep can't do. Append the list of files to above command or pipe a file through it, just as with regular grep. If you add the 's' modifier to the regex, the dot '.' also matches line endings, useful if you don't known how many lines you need are between parts of your pattern. Change '*' to '*?' to make it greedy, that is match only as few characters as possible. See also http://www.commandlinefu.com/commands/view/1764/display-a-block-of-text-with-awk to do a similar thing with awk. Edit: The undef has to be put in a begin-block, or a match in the first line would not be found.

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

command to change the exif date time of a image

create directory and set owner/group/mode in one shot

Grep inside Vim and navigate results
Will search for the given pattern and build a list of occurrences. Then you can use :copen and :cclose to toggle the list. When browsing the list, ENTER will take you to that line in the file.

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

pip install into current directory without virtualenv
For subsequent commands in the prefixed path: $ PYTHONPATH=$PWD/lib/python*/site-packages ./bin/pip --version

how many pages will my text files print on?
This gives a very rough estimate of how many pages your text files will print on. Assumes 60 lines per page, and does not take long lines into account.

Creates Solaris alternate boot environment on another zpool.
PS: 'lustatus' gives the list of all alternate boot environments.

repeat a command every one second
Short method of "while x=0; do foo ; sleep 1 ; done"


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: