Prepending text to a file with sed

Appending content to a file on Linux is pretty easy with >> but there’s no equivalent redirection to prepend content. Luckily, for every file manipulation problem on Linux there’s at least a dozen solutions.

Using sed with -i for inplace replacement of content in a file, you can match ^ for start of line, and then follow with the content you want to replace (in this case, insert).

VNC remote desktop to a Raspberry Pi

I normally ssh into my remote Raspberry Pi’s, but if you don’t have then attached to a monitor and need to get a desktop view of what’s going on, a VNC remote connection works great. Step by step instructions here.

Selecting multiple files in Midnight Commander

At one point file managers like Midnight Commander were the best thing ever. I just came across Midnight Commander on the RetroPie install for managing game roms, and got stuck trying to work out how to select multiple files. Pressing Insert selects/deselects.

There’s a good intro to using MC here.

Lightweight docker images for Java apps

There’s a number of posts (e.g. here) talking about the official Java docker images being on the large side – in Docker terms, the standard images at > 600MB before you even build your image containing you app are … pretty big.

Suggestions are to use a smaller image as a starting point, like Alpine Linux. It looks like at some point the official Java images have been updates to include a number of Alpine based images too.

Pulling down an OpenJDK 8 image, java:openjdk-8-jdk and then java:openjdk-8-alpine, there’s a massive size difference between the size of the two:

If you’re planning on running something lightweight like a Spring Boot app, looks like the provided Alpine images are a good starting point.