commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Display the amount of memory used by all the httpd processes. Great in case you are being Slashdoted!
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