Book Image

Learning Linux Shell Scripting - Second Edition

By : Ganesh Sanjiv Naik
Book Image

Learning Linux Shell Scripting - Second Edition

By: Ganesh Sanjiv Naik

Overview of this book

Linux is the most powerful and universally adopted OS. Shell is a program that gives the user direct interaction with the operating system. Scripts are collections of commands that are stored in a file. The shell reads this file and acts on commands as if they were typed on the keyboard. Learning Linux Shell Scripting covers Bash, GNU Bourne Again Shell, preparing you to work in the exciting world of Linux shell scripting. CentOS is a popular rpm-based stable and secured Linux distribution. Therefore, we have used CentOS distribution instead of Ubuntu distribution. Linux Shell Scripting is independent of Linux distributions, but we have covered both types of distros. We start with an introduction to the Shell environment and basic commands used. Next, we explore process management in Linux OS, real-world essentials such as debugging and perform Shell arithmetic fluently. You'll then take a step ahead and learn new and advanced topics in Shell scripting, such as decision making, starting up a system, and customizing a Linux environment. You will also learn about grep, stream editor, and AWK, which are very powerful text filters and editors. Finally, you'll get to grips with taking backup, using other language scripts in Shell Scripts as well as automating database administration tasks for MySQL and Oracle. By the end of this book, you will be able to confidently use your own shell scripts in the real world.
Table of Contents (17 chapters)

Comparison of shells

Initially, the Unix OS used a shell program called the Bourne shell. Then, eventually, many more shell programs were developed for different flavors of Unix. The following is some brief information about different shells:

  • sh—Bourne shell
  • csh—C shell
  • kshKorn shell
  • tcsh—enhanced C shell
  • bashGNU Bourne Again shell
  • zshextension to bash, ksh, and tcsh
  • pdkshextension to ksh

A brief comparison of various shells is presented in the following table:

Feature

Bourne

C

TC

Korn

Bash

Aliases

no

yes

yes

yes

yes

Command-line editing

no

no

yes

yes

yes

Advanced pattern matching

no

no

no

yes

yes

Filename completion

no

yes

yes

yes

yes

Directory stacks (pushd and popd)

no

yes

yes

no

yes

History

no

yes

yes

yes

yes

Functions

yes

no

no

Yes

yes

Key binding

no

no

yes

no

yes

Job control

no

yes

yes

yes

yes

Spelling correction

no

no

yes

no

yes

Prompt formatting

no

no

yes

no

yes

What we see here is that, generally, the syntax of all these shells is 95% similar.
In this book, we are going to follow Bash shell programming.