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

See multiple progress bars at once for multiple pipes with pv
In this example we convert a .tar.bz2 file to a .tar.gz file. If you don't have Pipe Viewer, you'll have to download it via apt-get install pv, etc.

ShellCheck all the bash/sh script under a specific directory excluding version control
This is a commodity one-liner that uses ShellCheck to assure some quality on bash and sh scripts under a specific directory. It ignores the files in .git directory. Just substitute "./.git/*" with "./.svn/*" for older and booring centralized version control. Just substitute ShellCheck with "rm" if your scripts are crap and you want to get rid of them :)

Create a bunch of dummy text files
Avoiding a for loop brought this time down to less than 3 seconds on my old machine. And just to be clear, 33554432 = 8192 * 4086.

convert MTS video file format into xvid/mp3 avi format

In Mac OS X, read the copy area (CMD + V) and convert text to audible speech

Resume a detached screen session, resizing to fit the current terminal
By default, screen tries to restore its old window sizes when attaching to resizable terminals. This command is the command-line equivalent to typing ^A F to fit an open screen session to the window.

Search commandlinefu from the command line
There's probably a more efficient way to do this rather than the relatively long perl program, but perl is my hammer, so text processing looks like a nail. This is of course a lot to type all at once. You can make it better by putting this somewhere: $ clf () { (curl -d "q=$@" http://www.commandlinefu.com/search/autocomplete 2>/dev/null) | egrep 'autocomplete|votes|destination' | perl -pi -e 's/$/\n\n/g;s/^ +|\([0-9]+ votes,//g;s/^\//http:\/\/commandlinefu.com\//g'; } Then, to look up any command, you can do this: $ clf diff This is similar to http://www.colivre.coop.br/Aurium/CLFUSearch except that it's just one line, so more in the spirit of CLF, in my opinion.

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

Find the package that installed a command

Generate a random text color in bash
The expression $(( $RANDOM * 6 / 32767 + 1 )) generates a random number between 1 and 6, which is then inserted into the escape sequence \e[3_m to switch the foreground color of the terminal to either red, green, yellow, blue, purple or cyan. The color can be reset using the escape sequence \e[0m. The full list of colors can be found here: https://wiki.archlinux.org/index.php/Color_Bash_Prompt#List_of_colors_for_prompt_and_Bash


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: