Chapter 3. Effective Script Writing
To write an effective script in shell, it is very important to know about the different utilities that shell provides. Similar to other programming languages, shell programming also requires a way to specify skipping or running certain commands under certain conditions. To perform a certain task on the list of elements, looping constructs are needed in shell as well.
In this chapter, we will cover topics such as if
, else
, case
, and select
that can be used to run a certain block of commands according to the condition. We will see the for
, while
, and until
constructs, which are used to loop over a certain block of commands in a script. We will see how the exit code, after the execution of a command or script, plays an important role in knowing whether a command was executed successfully or not. We will also see how a function can be defined in shell, which will allow us to write modular and reusable code from now on.
This chapter will cover the...