Posts Tagged ‘commandline’
Great post on Stack Exchange, How to correctly add a path to PATH?.
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 […]
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: archive.2014-08.tar.gz archive.2014-09.tar.gz archive.2014.10.tar.gz Now if you wish to extract your data from all three […]
This is a great one-liner which removes old kernel images and frees up space in your boot partition:
1 |
$sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')") |
This comes from the top answer to a question on ask ubuntu.
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 […]
Most digital cameras store Exif data in the JPEG photo files. This includes things like date and time, camera model and camera settings and in some cases even GPS coordinates. jhead is a very useful command line utility which can read and edit the Exif data. For example, you may wish to remove the data […]
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 […]
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 […]
Here’s a quick way to remove empty lines from a file using the Linux command line: cat file1 | sed /^$/d > file2 Where file1 is the input file containing empty lines and file2 is a newly created file with empty lines removed.
Changing the port number of SSH daemon is a quick way of reducing the number of SSH brute force attacks your server might face (check the file /var/log/auth.log to see if there are many failed SSH login attempts). Just to be on the safe side, create a backup copy of the SSH daemon config file. […]