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:
Sometimes you unzip a file that has no root folder and it spews files all over the place. This will clean up all of those files by deleting them.
Just an alternative with more advanced formating for readability purpose. It now uses colors (too much for me but it's a kind of proof-of-concept), and adjust columns.
This will get all links from a given URL, remove any duplicates, and output the result.
Quick and dirty one-liner to get the average ping(1) time from a server.
since awk was already there one can use it instead of the 2 greps. might not be faster, but fast enough
Tail is much faster than sed, awk because it doesn't check for regular expressions.
This one is a bit more robust -- the remote machine may not have an .ssh directory, and it may not have an authorized_keys file, but if it does already, and you want to replace your ssh public key for some reason, this will work in that case as well, without duplicating the entry.
In case sed and awk are not available you may use this to remove the last character from a string with "rev" and "cut".
like #9295, but awkish instead of perlish
This does the same thing that the command 'j_melis' submitted, but does it a lot quicker.
That command takes 43 seconds to complete on my system, while the command I submitted takes 6 seconds.
The improvement of this command over Strawp's original alternative is that you can specify the size of the words, in this particular case words between 3 and 5 character's long. It also excludes words that contain apostrophes, if you'd rather keep those words simply substitue [^'] for .
If you do not have shuf or an -R option in sort, you can fall back on awk. This provides maximum portability IMO. The command first collects words from the dictionary that match the criteria - in this case: lower case words with no punctuation that are 4 to 8 characters long. It then prints 4 random entries. I decided to print each word on a separate line to improve readability.
Outputs the real time it takes a Redis ping to run in thousands of a second without any proceeding 0's. Useful for logging or scripted action.
- all zips are in current folder
- FILENAME is file name that should be subsitute in all zips (new version of this file is in current folder)
If your version of curl does not support the --compressed option, use
curl -s http://funnyjunk.com | gunzip
curl -s --compressed http://funnyjunk.com
Replace .py with .rb or .java to get the LOC of that particular filetype. An alternative is http://www.commandlinefu.com/commands/view/2812/make-a-statistic-about-the-lines-of-code
count connections, group by IP and port
to be executed from root. this works well on most commercial unix systems, have not tried on linux systems.
How to force a userid to log out of a Linux host, by killing all processes owned by the user, including login shells:
Why use grep and awk?