• phone icon +44 7459 302492 email message icon info@uplatz.com
  • Register

Introduction to Shell Scripting

This is Shell Scripting tutorial by Uplatz explaining the concepts of shell programming with some practical examples and the shell code.
A Unix shell is a command language interpreter, the primary purpose of which is to translate command lines typed at a terminal into system actions. The shell itself is a program through which other programs are invoked. Although there are several different Unix shells, among them the C shell (csh), the Bourne shell and the Korn shell, the one most frequently used on Blake within Berkeley UNIX is the C shell.
The shell has some built-in functions, which it performs directly, but most commands that you enter cause the shell to execute programs that are external to the shell. This sets the shell apart from other command interpreters, because it is just another user program at the same time that it functions almost exclusively as a mechanism for invoking other programs.
One handy thing you can do with the shell is to use standard UNIX commands as building blocks to create your own new commands. To do this, you write a shell script, which can contain a number of commands, and then the file can be executed as one command.
Thus, a shell script is a text file that contains a sequence of commands for a UNIX-based operating system. It is called a shell script because it combines a sequence of commands, that would otherwise have to be typed into the keyboard one at a time, into a single script. The shell is the operating system's command-line interface (CLI) and interpreter for the set of commands that are used to communicate with the system.
A shell script is usually created for command sequences in which a user has a need to use repeatedly in order to save time. Like other programs, the shell script can contain parameters, comments and subcommands that the shell must follow. Users initiate the sequence of commands in the shell script by simply entering the file name on a command line.

Types of shells
In Unix and Linux, the two major types of shell scripts are:
1) Bourne again shells (BASH)- BASH is the default shell for Unix version 7. The character for prompting a bourne again shell is $.
2) C shells- A C shell is run in a text terminal window and is able to easily read file commands. The character for prompting a C shell is %.
How shell scripting works
The basic steps involved with shell scripting are writing the script, making the script accessible to the shell and giving the shell execute permission.
Shell scripts contain ASCII text and are written using a text editor, word processor or graphical user interface (GUI). The content of the script is a series of commands in a language that can be interpreted by the shell. Functions that shell scripts support include loops, variables, if/then/else statements, arrays and shortcuts.

Examples of shell script applications: Automating the code compiling process, Running a program or creating a program environment, Completing batch, Manipulating files, Linking existing programs together, Executing routine backups, Monitoring a system, etc.
Inquiry to Uplatz
Unix and Shell ScriptingUnix TrainingShell Scripting Training