July 15th, 2016 | Tags: , ,

Great post on Stack Exchange, How to correctly add a path to PATH?.

July 15th, 2016 | Tags: , , ,

Lots of issues with Network Manager in Ubuntu 16.06 LTS, in particular connecting to wifi after suspend/resume. Restarting the Network Manager service seems to work for me.

January 26th, 2016 | Tags: , ,

Here’s the fix for a problem where Nautilus shows hidden files by default.

  • $dconf-editor
  • org -> gtk -> settings -> file-chooser
  • Uncheck show-hidden
  • Close Nautilus and open again
October 26th, 2014 | Tags: ,

I have just installed the Crayon Syntax Highlighter plugin on this blog. Obviously a lot of the posts that I put here contain code snippets, so this great plugin will make that a little neater with feauters such as line numbers toggle, syntax highlight, copy into clipboard and many more. Over time I hope to update the existing content on the site to make use of the plugin.

October 18th, 2014 | Tags: , , ,

In this post we look at how text data can be transposed in a shell script. Suppose you have a comma-delimited text file (csv) which looks like this:


…and so on. Perhaps this is a set of sensor readings over a period of time, and in this case there are four readings per day. For further analysis it might be more suitable to store each date on a single line with the four readings as columns. In other words we want to transpose rows to columns, i.e. pivot the values on date. The file should look like this:


Since this needs to process multiple input rows of to produce one output row, sed will not be suitable. Instead we need to use awk. The following tiny script will do the trick.

Now, what exactly is this doing? First, we need to specify that the file is comma delimited, which is what -F, does. Next, the main principle is that the code stored between the curly brackets will be executed individually for each row, however a session (including variables) is maintained throughout the execution of entire input. So val is a variable into which we are storing the third field on each row ($3) prepended by a comma. The if statement checks whether the row number (NR is a special built in variable which holds the number of the row being currently processed) is divisible by four (% is the modulo function, as in most languages). If yes, we print the date which is the first column ($1) as well as the val variable which now has the values from the previous three rows as well as this one, separated by commas. The variable is then reset.

Obviously, we are making an assumption here that the data is uniform, i.e. that there are exactly four readings available for each day; otherwise the script would be a little more complex.

October 18th, 2014 | Tags: , ,

Suppose you have a monthly process to archive some data such as log files etc. Each month a separate archive file is created, and so after a few months you will have several archive files – for example as shown below:


Now if you wish to extract your data from all three files, you could run individual commands such as:

This works fine. However the following won’t work if you want a one-line which does them all in one short:

Basically the way that tar command works, if more than one filename (or an expansion) is passed as an argument, it will look for the second, third, etc. files inside the first file. So the error is saying it cannot find the second and third archive file inside the first one (archive.2014-08.tar.gz). So in essence the tar command itself really does have to be called individually for each file. The way to simplify this on a one-liner is to use the xargs command which will do exactly that:

October 25th, 2013 | Tags: , ,

FPrint is a PPA with packages for fingerprint-based authentication. Website includes good documentation on how to install and set it up.

October 16th, 2013 | Tags: , , ,

This is a great one-liner which removes old kernel images and frees up space in your boot partition:

This comes from the top answer to a question on ask ubuntu.

September 20th, 2013 | Tags:

Here’s an article on Lego’s Land on how to reorder accounts in the left pane of Thunderbird.

August 16th, 2012 | Tags: , ,

The Nokia N900 is getting a little old now, but it still an amazing piece of kit. This post has a few pointers for making the most out of command line usage it enables.

  • Command Line Execution Widget: This widget lets you run commands from the desktop and outputs the results..
  • Cmd Shortcuts: Allows you to quickly run your own defined commands.
  • gPodder: This excellent podcast catcher comes with a command line interface. Run gpo from the terminal to get the full list of options.
  • FeedingIt: This RSS aggregator can be run from the command line. The known options are /usr/bin/FeedingIt update and /usr/bin/FeedingIt status.
  • Alarmed: This is a graphical interface to the cron scheduler. Apart from neat access to phone functionality (e.g. switching profiles, networking, and yes alarms) it also allows arbitrary shell commands to be scheduled. This is particularly useful with the gPodder and FeedingIt mentioned above. To use this tool you currently need to enable the testing repository.