Pipes in Linux

1.0 Interprocess communication

A process is an active operating system entity which executes programs. Normally, a process, like a specialist, does one particular job (well). In real life, there are complex workflows and we, often, have multiple processes collaborating to accomplish certain objectives.… Read more

fork and exec in Linux

1.0 fork and exec system calls

Suppose we wish to write a "shell program" which would execute another program. Now, in a computing system, a process executes a program. So this shell program (or, process, at run time) needs to create a process which would execute a program.… Read more

Using Git

1.0 Introduction

Git commands for common source code management use cases are listed.

2.0 Install Git

On a Ubuntu Linux system, Git can be installed with the command,

$ sudo apt-get install git

3.0 Set Identity

Before using Git, the user's identity (name, email) has to be set

$ git config --global user.email "user1@example.com"
$ git config --global user.name "Joe Bloggs"

4.0 Initialize git repository

The first job for putting a project under source code management is to create a repository.… Read more

Bash idioms

In a nutshell

bash idioms are tiny scripts, mostly one-liners, that accomplish a lot and can be used as building blocks in bigger scripts.

1.0 Find most frequent words

Suppose we have a bunch of text files and we wish to find the most frequently used words in those files, we can do that with the command,

cat * | tr -sc '[:graph:]' '\n' | sort | uniq -c | sort -nr

First, we capture all input with cat and pipe it to the tr command.… Read more

tr Command in Linux

1.0 tr

The tr command is a filter which reads the standard input, translates or deletes characters and writes on its standard output. The tr command syntax is,

tr [OPTION]... SET1 [SET2]

tr transliterates characters from SET1 into corresponding characters of SET2 in input and writes resulting text on the standard output.… Read more

Comm Command in Linux

1.0 comm

The comm command compares two sorted files and gives output in three columns. The first column has lines which are present only in the first file. The second column contains lines which are present only in the second file.… Read more

Sort command in Linux

1.0 Sort

The sort command is for sorting lines in text files. For example, if we have a file names, we can sort it with the sort command,

$ cat names
John Doe
Jane Doe
John Roe
Richard Roe
Tommy Atkins
Max Mustermann
Erika Mustermann
Joe Bloggs
$ sort names
Erika Mustermann
Jane Doe
Joe Bloggs
John Doe
John Roe
Max Mustermann
Richard Roe
Tommy Atkins

The words in the input lines are fields, which are numbered 1 onwards.… Read more

Awk Tutorial


1.0 awk

awk is a filter which takes the input and gives output after matching desired patterns and doing processing linked to matched patterns. awk is well suited for processing voluminous raw text data and producing statistical reports from it.

awk is named after the first character of the names of its designers, Al Aho, Peter Weinberger and Brian Kernighan, who developed it for Unix systems in the 1970s.… Read more