Monthly Archives: November 2011

In-Line Search And Replace With Perl Regular Expressions.

Go ahead and skip right to the examples if you’re in a hurry 😉

perl -p -i -e 's/change this/to that/g' file1 file2 file3...

Got Regexes? Regular Expressions (also known as regexes, regexen, and regexps) open up a world of new power tools to you when you need to automate text analysis or manipulations such as massive search and replace operations in one or multiple directories. Such a task oft befalls the sysadmin/developer/commandline ninja.

So case in point: If you find yourself needing to do some file correction in place Continue reading

My Ever-Evolving Bash Profile

Please feel free to experiment with the following ~/.bash_profile goodness of my own, and save away to yours what tasty morsels that you find useful.

Exactly what each line does below is left as an exercise to the reader 😉 but to summarize— these aliases speed up common tasks, keep embedded timestamps in your history, offer shortcuts to longer-but-often-useful command sequences, highlight your command prompt, and enable colorful output for frequently used commands like grep, help monitor CPU and GPU temperature Continue reading

Remove An IP Address Ban That Has Been Errantly Blacklisted By Denyhosts

denyhosts is an excellent utility to prevent brute-force SSH attacks against your server. One shortcoming it has is that it is difficult to get a blacklisted IP address back out of the, well, blacklist. Simply removing its entry from /etc/hosts.deny will not keep denyhosts from doing its job of blocking what it deemed to be a threat. So what to do? Enter this script (below). It’s yours for the taking. Continue reading

Monitor Processor Temperature From The Command Line

Do you ever need to/want to know how hot your processors are running? There’s a way!

Sure, there are handy gui tools for things like this, but for our purposes, sometimes a quick, clean little shell code snippet gets the job done quite nicely. Take, for instance when you are running something CPU intensive, like transcoding video with handbrake or maybe folding proteins. Those kinds of computations really give your processor(s) a heavy workout, and often run them up to hotter than recommended temperatures (usually ~40 degrees celcius) which can shorten their lifespan. Continue reading