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.
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:
Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:
slashdot.org webserver adds an X-Bender or X-Fry HTTP header to every response!
On a Gentoo system, this command will tell you which packets you have installed and sort them by how much space they consume. Good for finding out space-hogs when tidying up disk space.
Useful for deleting old unused log files.
This command will generate "CHECK TABLE `db_name.table_name` ;" statements for all tables present in databases on a MySQL server, which can be piped into the mysql command. (Can also be altered to perform OPTIMIZE and REPAIR functions.)
Tested on MySQL 4.x and 5.x systems in a Linux environment under bash.
Convert comma separated files to tab separated files.
(MySQL eats tab separated files with much less instruction than comma seperated files.)
Limited, but useful construct to extract text embedded in XML tags. This will only work if bar is all on one line.
If nobody posts an alternative for the multiline sed version, I'll figure it out later...
a shorter version
a variation of avi4now's command - thanks by the way!
If your XML is appended to a line with a time stamp or other leading text irrelevant to the XML, then you can append a s/foo/bar/ command, like this:
sed -n /<Tag>/,/<\/Tag>/p; s/.*\(<Tag.*\)/\1/' logfile.log
Just a handy way to get all the unique links from inside all the html files inside a directory. Can be handy on scripts etc.
Save the script as: sort_file
Usage: sort_file < sort_me.csv > out_file.csv
This script was originally posted by Admiral Beotch in LinuxQuestions.org on the Linux-Software forum.
I modified this script to make it more portable.
What happens if there is more than a single space between words, or spaces and tabs? This command will remove duplicate spaces and tabs.
The "-r" switch allows for extended regular expressions. No additional piping necessary.
Note you have also the --xml option ;)
You can replace "sort -nu" with "sort -u" for a word list sorted or "sort -R" for a random-sorted line