Posts Tagged ‘sed’

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: 2014-10-01,Reading1,20.3 2014-10-01,Reading2,21.5 2014-10-01,Reading3,24.0 2014-10-01,Reading4,22.2 2014-10-02,Reading1,20.5 2014-10-02,Reading2,21.5 2014-10-02,Reading3,24.1 2014-10-02,Reading4,22.4 2014-10-03,Reading1,20.5 2014-10-03,Reading2,21.7 2014-10-03,Reading3,24.2 2014-10-03,Reading4,22.5 …and so on. Perhaps this is a set of sensor readings over a period of […]

Saturday, October 18th, 2014 at 15:50 | 0 comments
Categories: Linux

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.

Wednesday, October 16th, 2013 at 08:39 | 0 comments
Categories: Linux

GNU/Linux includes many utilities for working with text files through the shell. In this post we take a quick look at accessing and manipulating text files in a “column-wise” mode. Suppose you have the following two files, each with two columns separated by the TAB character. $cat file1 Alice   Paris Bob     Tokyo Mary    London John    New York $cat file2 […]

Monday, October 17th, 2011 at 17:02 | 0 comments
Categories: Linux

Sed can be used to strip out all HTML or XML tags from a file and get the plain text version. Suppose you have file gnulinux.html with the following contents: <p>The combination of <a href=“/gnu/linux-and-gnu.html“>GNU and Linux</a> is the <strong>GNU/Linux operating system</strong>, now used by millions and sometimes incorrectly called simply “Linux“.</p> Tempting but incorrect […]

Monday, October 17th, 2011 at 12:16 | 0 comments
Categories: Linux