O'Reilly logo

Fundamentals of Linux by Oliver Pelz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introduction to Bash shell scripting

In this section, we will introduce you to the core concept of Bash shell scripting. Another very important feature of Bash shell scripts are functions. We use functions excessively in Bash shell scripts to make reoccurring tasks or commands reusable. Functions encapsulate a task to make it more modular. Functions usually take in data, process it, and return a result. Once a function is written, it can be used over and over again, but we can also work with functions on the command line.

Let's discuss the general syntax of a function by creating one:

$ say_hello90 {
>echo "My name is $1";
>}  

The first word is the function name followed by opening and closing brackets, which are used to define a function, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required