Site icon Affordable Assignment Experts Help Online – QualityAssignmentHelp

IMPORTANCE OF SHELL SCRIPT IN PROGRAMMING

Shell script has proved to have advantage over interpreted programming languages in a number of situations. Even though shell scripts written in bash for example can call Unix programs, have flow controlled as well as check out the existence of a particular file, this can be done by modern programming languages such as python and ruby as well. So whats the advantage of shell script have above the rest?

It has been observed that when one writes a shell script , it usually take a shorter time for they are faster to write that other languages as well as having an interactive debugging process. The file selection is first and they are generally quick to start.

 When one is obtaining data from a given program to another that is in text form or when working with files, shells have features that are specialized to these tasks. They are manageable when compared to other scripting languages such as Python.  Another advantage that shell scripting has is that, commands that one utilizes are identical to the ones used from the command line. Matthew and Stones (1996, p. 202) maintain that when one is halfway done scripting the operation if one can operate in the shell Shell scripts do function with no additional application of any other modern language such as BSD or latest UNIX versions as they come as interpreted languages. Let us take the example below to make it clearer.

Below is a bash script that is to move to a particular directory all PNG files from the present directory;

 #!/usr/bin/sh

mv *.png $1

the same version in python would be as follows;

#!/usr/bin/python

import sys, shutil, glob

for filename in glob.iglob(“./*.png”):

    shutil.move(filename, sys.argv[1])

from the above example one can note that by counting the lines and characters, Python is more longer than the bash script. Three libraries are indispensable in the libraries importation when one is using Python as compared to bash where all u require for the task is available in one package. Bash in moving the files will have as an element of the semantics the mv command unlike Python that will require a loop (p.202).

Though being advantageous in the above circumstances, shell scripting comes with a number of limitations. It has been rated as leading to costly errors such as the typing ones. Let’s take an instance when one intends to mean rm-rf*/ and types rm-rf* / , this can be quite detrimental as the command deletes everything in the root-directories as opposed to the sub-directory.

Exit mobile version