Multi Line Sed

Sed is a powerful command line tool for manipulating text, using regular expressions (regex). But the default behavior of sed is to just operate on a single line of input text, then starting over on the next line, etc. Sometimes we would instead want to manipulate text based on its context, i.e. based on content found on surrounding lines of text.

For example, in the JSON here below we might want to change the label in object with id "ZoomIn", regardless of its previous value:

Xargs file rename

Let's say you want to rename files that match a certain pattern, and are spread out amongst many other files in a folder tree. Using pipes in a terminal, this can be achieved easily.

The biggest problem is that you want to give mv two dynamic arguments, with the second one calculated from the first one. Pipes only forward a single stream. However, we can use the p command in sed, and a semicolon separator, to output two lines for every single input line: one original line and one line calculated from the original.

Emails in Perl

Perl is a powerful script language that's been around since the eighties. On Perl modules can be found for almost any task imaginable. Unfortunately some of those modules are poorly maintained, or simply poorly written to begin with.


The easiest way to get a Ubuntu web server up and running is to install the lamp-server package, which contains Apache2, MySQL and PHP.

sudo apt-get install lamp-server^

Then, enable these essential Apache2 modules:

sudo a2enmod ssl
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod expires

Disable access logs to save time and space:

sudo a2disconf other-vhosts-access-log

These packages also come in handy for a web server:

Find and replace

When coding, you often find yourself wanting to replace some word in all the files of a folder tree. Fortunately that can be done easily in Linux.

Disk cloning

When setting up a server, the Ubuntu LTS (Long Term Support) releases are a great OS choice, since they are free and guaranteed to get security updates for five years after the initial release. But eventually even an LTS release will become obsolete. Fortunately, the server can quite easily be upgraded to the latest LTS release, as seen here:

Noone left behind

The expression backward compatibility probably doesn't rank very high on a list of software developers' favorites. At least not for those developers tasked with providing backward compatibility in libraries or frameworks. Which is why I'm really impressed by how well it works in the Android framework!

Headless Android

As I've previously mentioned, having a server on the Internet can be very useful. Keeping the server headless (not installing a GUI) reduces the system requirements, and the need for security upgrades/maintenance. However, Android development becomes a bit trickier on a headless server, considering that Eclipse and graphical Android tools cannot be used.


Subscribe to Blog