grep Command in Linux

1.0 grep

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

vi editor commands


vi is a classic text editor that has been available with Unix systems right from the beginning. vi has been a very popular text editor and one can edit files very efficiently using it. In this tutorial, we look at some of the vi commands that make it such a powerful editor.… Read more