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:
-sl : show just file names
Ever ask yourself "How much data would be lost if I pressed the reset button?"
Scary, isn't it?
Expand a URL, aka do a head request, and get the URL. Copy this value to clipboard.
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.
Videos are found using their MIME type. Thus no need to for an extension for the video file.
This is a efficent version of "jnash" cmd (4086). Thanks for jnash. This cmd will only show video files while his cmd show files having "video" anywhere in path.
Find the usage of a switch with out searching through the entire man page.
Usage: manswitch [cmd] [switch]
manswitch grep silent
In simple words
man <cmd> | grep "\-<switch>"
man grep | grep "\-o"
This is not a standard method but works.
No final count, but clean and simple output.
Much better alternatives - grep-alikes using perl regexps. With more options, and nicer outputs.
Grabs the Apache config file (yielded from httpd) and returns the path specified as DocumentRoot.
If you've ever tried "grep -P" you know how terrible it is. Even the man page describes it as "highly experimental". This function will let you 'grep' pipes and files using Perl syntax for regular expressions.
The first argument is the pattern, e.g. '/foo/'. The second argument is a filename (optional).
ls -F | grep /\$
but will break on directories containing newlines. Or the safe, POSIX sh way (but will miss dotfiles):
for i in *; do test -d "./$i" && printf "%s\n" "$i"; done
Normally, if you just want to see directories you'd use brianmuckian's command 'ls -d *\', but I ran into problems trying to use that command in my script because there are often multiple directories per line. If you need to script something with directories and want to guarantee that there is only one entry per line, this is the fastest way i know
This will affect all invocations of grep, even when it is called from inside a script.
If your version of curl does not support the --compressed option, use
curl -s http://funnyjunk.com | gunzip
curl -s --compressed http://funnyjunk.com
There's nothing particularly novel about this combination of find, grep, and wc, I'm just putting it here in case I want it again.
ack search recursively by default
How to force a userid to log out of a Linux host, by killing all processes owned by the user, including login shells:
This example command fetches 'example.com' webpage and then fetches+saves all PDF files listed (linked to) on that webpage.
[*Note: of course there are no PDFs on example.com. This is just an example]
Original submitter's command spawns a "grep" process for every file found. Mine spawns one grep with a long list of all matching files to search in. Learn xargs, everyone! It's a very powerful and always available tool.
Why use grep and awk?