commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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.
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:
Don't want to open up an editor just to view a bunch of XML files in an easy to read format? Now you can do it from the comfort of your own command line! :-) This creates a new function, xmlpager, which shows an XML file in its entirety, but with the actual content (non-tag text) highlighted. It does this by setting the foreground to color #4 (red) after every tag and resets it before the next tag. (Hint: try `tput bold` as an alternative). I use 'xmlindent' to neatly reflow and indent the text, but, of course, that's optional. If you don't have xmlindent, just replace it with 'cat'. Additionally, this example shows piping into the optional 'less' pager; note the -r option which allows raw escape codes to be passed to the terminal.
Opens up a tab separated file in less with columns printed prettily
grep for specific function invocations in this case, wither "emit" or "on" with "leader".
This will open the manpage for "foobar", and display all instances of "searched_string". You can traverse through them by pressing "n"
I've been using colordiff for years. wdiff is the new fav, except its colors. Word delimited diffs are more interleaved, easing the chore of associating big blocks of changes.
kpsewhich is a tool for path and file lookup. It is a front-end of the kpathsea library. For one or more given package or file names it returns the complete path from within the TeX installation, that one which the compiler would actually use. Via backticks we can use it as argument to less, more, or any editor. For example:
gedit `kpsewhich hyperref.sty`
usage: dng BRE [selection]
default selection is the last match
DNS is ok, but although domainnames may be easier to remember than IP numbers, it still requires typing them out. This can be error-prone. Even more so than typing IPv4 numbers, depending on the domainname, its length and complexity.
On Debian/Ubuntu the pygments script is called pygmentize and can be found in the python-pygments package.
For an overview of all available lexers, formatters, styles and filters use
Here is an example using more options
pygmentize -f 256 -l sh -F whitespace:spaces=True,tabs=True -O style=borland ~/.bashrc | less -R
just like the original - just colored and with less
Use the following key binding to search
: Jump to line number n. Default is the start of the file.
: Jump to line number n. Default is the end of the file.
: Search for pattern. Regular expressions can be used. [/ = slash] Press / and then Enter to repeat the previous search pattern. Press ESC and then u to undo search highlighting.
: Go to next match (after a successful search).
: Go to previous match.
: Mark the current position with letter.
: Return to position letter. [' = single quote]
'^ or g
: Go to start of file.
'$ or G
: Go to end of file.
: Save current content (got from another program like grep) in a file.
= or Ctrl+g
: File information.
: continually read information from file and follow its end. Useful for logs watching. Use Ctrl+c to exit this mode.
: Toggle command-line option -option.
Useful for situations where you have word lists or dictionaries that range from hundreds of megabytes to several gigabytes in size. Replace file.lst with your wordlist, replace 50000 with however many lines you want the resulting list to be in total. The result will be redirected to output.txt in the current working directory. It may be helpful to run wc -l file.lst to find out how many lines the word list is first, then divide that in half to figure out what value to put for the head -n part of the command.
This version now adds a header with consecutive numbering.
manswitch grep -o
This will take you to the relevant part of the man page, so you can see the description of the switch underneath.
This is a simple bash function and a key binding that uses commandlinefu's simple and easy search API. It prompts for a search term, then it uses curl to search commandline fu, and highlights the search results with less.