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

Skip over .svn directories when using the
Put the positive clauses after the '-o' option.

create a new script, automatically populating the shebang line, editing the script, and making it executable.
The first argument is the interpreter for your script, the second argument is the name of the script to create.

Convert the contents of a directory listing into a colon-separated environment variable
Useful for making a CLASSPATH out of a list of JAR files, for example. Also: export CLASSPATH=.:$(find ./lib -name '*.jar' -printf '%p:')

open two files on top of each other in vim (one window, two panes)

which procs have $PATH_REGEX open?
faster than lsof by at least x2 on my box.

IFS - use entire lines in your for cycles
When you use a "for" construct, it cycles on every word. If you want to cycle on a line-by-line basis (and, well, you can't use xargs -n1 :D), you can set the IFS variable to .

Search some text from all files inside a directory

Display PHP files that directly instantiate a given class
This greps all PHP files for a given classname and displays both the file and the usage.

Show all available colors on your terminal.
Using perl and tput, show all the colors with numbers that your actual $TERM can handle. If want to remove the numbers at beginning of new line, it should be something like this: $perl -E 'say `tput setb $_`," "x `tput cols`, `tput sgr0` for 0 .. (`tput colors` - 1)'

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


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: