Getting Started with Bash Shell Programming in Linux

Getting Started With Shell Programming

INTRODUCTION

In Linux, Bash is the name of the shell or command language interpreter. Bourne-Again SHELL, or often BASH, references Stephen Bourne, the creator of the first Unix sh shell included in the 7th Edition of Unix made by Bell Labs. Developed by the GNU Project, Bash is the default shell in most Linux distributions and retains compatibility with the original sh UNIX shell while incorporating features from both ksh (Korn shell) and csh (C shell). Bash provides powerful scripting capabilities and is widely used for automating tasks, managing systems, and interacting with the operating system at a low level. 

Quoting from the official Bash home page:

The GNU operating system will use Bash as its default shell or command language interpreter. It tries to follow the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It provides more advanced tools than sh for programming as well as interactive execution. Bash scripts run fine if you try them directly in Bash, unlike in MS-DOS.

The improvements offered by BASH include

Bash syntax is a modern replacement for the Bourne shell syntax. Generally, it is easy to run Bourne shell scripts in Bash.

  • Command line editing.
  • Command line completion.
  • Unlimited size command history.
  • Prompt control.
  • Indexed arrays of unlimited size (Arrays)
  • Integers can be added, subtracted, and multiplied in any base from two to sixty-four.
  • Bash – POSIX Mode: Bash adapts its behavior according to what the POSIX standard requires.

Shell commands

The bash shell has commands that can be categorized as follows:

  • Internal commands (built-ins) are included within the shell and can be used simply by giving the command without any options.
  • Separate external binaries from the system are kept in /sbin, /usr/sbin, /usr/bin, /bin, or /usr/local/bin directories.

The purpose and use of shells in a Linux system

In Linux, you can use shell for a variety of reasons. The Linux user environment consists of these components:

Kernel—The main part of Linux that controls everything.

Shell creates a link that allows users to use the kernel.

 Terminal emulator—xterm is a terminal emulator designed to run in the X Window System. Lang allows people to enter commands and display the results on the screen.

 Linux Desktop and Windows Manager—Linux Desktop contains many software applications. You can use the file manager, the windows manager, and also the terminal emulator, among other things. Two examples of the complete desktop environment in Linux are KDE and Gnome.

Other standard shells

Most of the work in Linux is carried out using a command-line shell. Bash is already installed when you install Linux. Linux has many more shells that are available to use:

  • tcsh- An updated version of csh, the C shell.
  • The real version of Korn shell, as offered by AT&T, is called ksh.
  • Logging in to BSD puts you in the csh shell which offers C-like syntax.
  • zsh A powerful interactive shell.
  • scsh- A Scheme programming language that has an Unix shell included.

Conclusion:

The Indian Institute of Embedded Systems (IIES) is a renowned institution that offers top-notch education and training in the field of embedded systems. With its comprehensive curriculum and experienced faculty, IIES is a leading choice for individuals aspiring to excel in this domain.