Given an nginx web server log file, we might like to know who are the visitors to our website. One can go line by line through the log file, but that is tedious. It would be nice if we can get one line per client visiting the website, giving the IP address of the visitor and how many times that client has visited.… Read more
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 "firstname.lastname@example.org"
$ 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 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
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
grep is a program for searching a given string pattern in files. It searches the files for the pattern and prints the lines that contain strings matching the pattern. For example,
$ # grep pattern filenames ...
$ grep 'hbox' find.c
GtkWidget *window, *scrolled_win, *hbox, *vbox, *find;
hbox = gtk_hbox_new (FALSE, 5);
gtk_box_pack_start (GTK_BOX (hbox), w -entry, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), find, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
2.0 grep Command Syntax
grep [OPTIONS] pattern [file ...]
grep [OPTIONS] [-e pattern | -f file ] [file ...]
3.0 Regular Expressions
The pattern, mentioned above, is a regular expression.… Read more
A shell provides a user interface to a computer system. There are two types of shells, the command line interface (CLI) and the graphical user interface (GUI). In this tutorial, we describe the command line interface shell only and refer to it simply as
shell.… Read more
In Linux, each files has nine permission bits. There are three basic permissions, read (r), write (w) and execute (x), for a file. These three permissions are there for the owner (o) of the file, the group (g) set for the file and the "others" (o).… Read more
cron is a daemon that executes programs for users periodically at predefined times. The cron daemon or service is started by the init process during system initialization. cron comes from chronos, the Greek word for time. cron was authored by Brian Kernighan in Version 7 Unix.… Read more