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

add the result of a command into vi
in command mode, navigate your cursor to the line where you want the command output to appear, and hit "!!". No need to enter edit mode or even type a ":" (colon).

Outputs files with ascii art in the intended form.
Files containing ascii art (e.g. with .nfo extension) are typically not correctly reproduced at the command line when using cat. With iconv one can easily write a wrapper to solve this: $ #!/bin/bash $ if [ -z "$@" ]; then echo "Usage: $(basename $0) file [file] ..." $ else iconv -f437 -tutf8 "$@"; fi $ exit 0

Takes all file except file between !()
Go to tmp : cd /tmp; mkdir retmp; cd retmp Create 10 files : for i in {1..10}; do touch test$i; done Remove all files except test10 : rm !(test10)

Install pip with Proxy
Installs pip packages defining a proxy

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

Create and replay macros in vim
You can record, then replay a series of keystrokes in vim. In command mode 'q', then a letter [a-zA-Z] starts macro recording mode. Enter a series of vim commands. When done, enter command mode again, and press 'q' to stop recording. To replay, enter command mode, then press @{letter}

Search through all installed packages names (on RPM systems)
You can use wildcard with rpm search but you have to do 2 things: 1. use "-a" switch (means "all") with query ("-q") switch - argument is a pattern to use while searching for package names of all installed packages 2. protect wildcards, so that shell could not eat them - escape it with backslash ("\") or enclose all pattern between apostrophes ("'"): $ rpm -qa 'co*de' As you can see above it is possible to insert wildcards into middle of the pattern. If you want, you can add "-i" or another rpm query options, "-i" will print package information for all installed packages matching pattern.

Find jpeg images and copy them to a central location
Use if you have pictures all over the place and you want to copy them to a central location Synopsis: Find jpg files translate all file names to lowercase backup existing, don't overwrite, preserve mode ownership and timestamps copy to a central location

Print a random 8 digit number
Don't need to pipe the output into rs if you just tell jot to use a null separator character.

Touch a file using a timestamp embedded in the file name.
tstouch takes two arguments: a filename containing a timestamp, and an extended regular expression with the parenthesized section matching a timestamp of the form YYYYMMDDhhmm or YYYYMMDDhhmm.ss. It then touches the file with that timestamp.


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: